Skip to content

fix(runtime): handle input=None in generic handler#286

Open
deanq wants to merge 3 commits intomainfrom
fix/AE-2317-generic-handler-input-none
Open

fix(runtime): handle input=None in generic handler#286
deanq wants to merge 3 commits intomainfrom
fix/AE-2317-generic-handler-input-none

Conversation

@deanq
Copy link
Member

@deanq deanq commented Mar 25, 2026

Summary

  • Fix AttributeError crash when malformed job sends {"input": null} to generic handler
  • Changed job.get("input", {}) to job.get("input") or {} in both create_handler and create_deployed_handler — the default {} only applies when the key is missing, not when it's explicitly null
  • Added tests for input=None and missing input key scenarios

Test plan

  • test_create_handler_input_none — verifies graceful error response instead of crash
  • test_create_handler_input_missing — verifies missing input key handled
  • All 2491 existing tests pass
  • Coverage at 85.79%

Fixes AE-2317

@deanq deanq requested a review from Copilot March 25, 2026 20:48
@deanq deanq force-pushed the fix/AE-2317-generic-handler-input-none branch from 369da3e to bb144f1 Compare March 25, 2026 20:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a runtime crash in the generic handler when a malformed job payload provides {"input": null} by ensuring handler code can safely proceed without AttributeError.

Changes:

  • Update create_handler and create_deployed_handler to treat job["input"] == None as an empty dict.
  • Add unit tests covering input=None and missing input key for both handler factories.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/runpod_flash/runtime/generic_handler.py Normalizes job["input"] to {} when falsy to avoid .get() crashes.
tests/unit/runtime/test_generic_handler.py Adds regression tests for input=None and missing input scenarios for both handler types.
Comments suppressed due to low confidence (1)

src/runpod_flash/runtime/generic_handler.py:176

  • With input=None now normalized to {}, function_name becomes None and the handler returns "Function 'None' not found...". Consider explicitly detecting a missing/empty function_name and returning a clearer error (e.g., that job['input']['function_name'] is required) to make malformed-job debugging easier.
        job_input = job.get("input") or {}
        function_name = job_input.get("function_name")
        execution_type = job_input.get("execution_type", "function")

        if function_name not in function_registry:
            return {
                "success": False,
                "error": f"Function '{function_name}' not found in registry. "

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

deanq added 3 commits March 25, 2026 16:14
`job.get("input", {})` returns None when input is explicitly null,
causing AttributeError on the subsequent `.get()` call. Use `or {}`
to coalesce both missing and null input to empty dict.

Fixes AE-2317
- Add tests for create_deployed_handler with input=None and missing input
- Tighten create_handler assertions to verify "not found" error message
Address review feedback: replace `or {}` with explicit `is None` check
and add type validation to reject non-dict input types. Remove duplicate
test_create_deployed_handler_input_missing (covered in deployed handler
tests). Add type-validation tests for both handlers.
@deanq deanq force-pushed the fix/AE-2317-generic-handler-input-none branch from 7d92052 to 865c2e5 Compare March 25, 2026 23:14
@deanq deanq requested a review from Copilot March 25, 2026 23:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants