fix(runtime): handle input=None in generic handler#286
Open
Conversation
369da3e to
bb144f1
Compare
Contributor
There was a problem hiding this comment.
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_handlerandcreate_deployed_handlerto treatjob["input"] == Noneas an empty dict. - Add unit tests covering
input=Noneand missinginputkey 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=Nonenow normalized to{},function_namebecomesNoneand the handler returns "Function 'None' not found...". Consider explicitly detecting a missing/emptyfunction_nameand returning a clearer error (e.g., thatjob['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.
`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.
7d92052 to
865c2e5
Compare
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AttributeErrorcrash when malformed job sends{"input": null}to generic handlerjob.get("input", {})tojob.get("input") or {}in bothcreate_handlerandcreate_deployed_handler— the default{}only applies when the key is missing, not when it's explicitlynullinput=Noneand missinginputkey scenariosTest plan
test_create_handler_input_none— verifies graceful error response instead of crashtest_create_handler_input_missing— verifies missing input key handledFixes AE-2317