Fix: return 404 for invalid app_name in /run and /run_sse endpoints#5376
Open
AbhishekMauryaGEEK wants to merge 3 commits intogoogle:mainfrom
Open
Fix: return 404 for invalid app_name in /run and /run_sse endpoints#5376AbhishekMauryaGEEK wants to merge 3 commits intogoogle:mainfrom
AbhishekMauryaGEEK wants to merge 3 commits intogoogle:mainfrom
Conversation
…04 instead of 500)
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
Hi maintainers, this PR fixes improper error handling for invalid app_name CLA has been signed and checks are passing. |
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.
Fixes #5374
Summary
Fixes improper error handling in the ADK FastAPI server where invalid
app_namevalues caused unhandled exceptions and resulted in HTTP 500responses.
This change ensures that invalid or non-existent
app_nameinputs return acontrolled
404 Not Foundresponse instead.Problem
The endpoints:
POST /runPOST /run_ssecall
get_runner_async(app_name), which raises aValueErrorwhen the agentcannot be found.
This exception was not handled at the API layer, causing FastAPI to return a
500 Internal Server Error.Solution
Wrap the
get_runner_asynccall in atry/exceptblock and convertValueErrorinto a404 HTTPException.Example:
This aligns the response with expected API semantics for missing resources.
Error Handling Improvements:
try/exceptblock to handleValueErrorwhen callingget_runner_async, returning a 404 HTTP response if the specified app is not found.Logging Changes:
run_agentendpoint, simplifying the response logic.HTTP 404 Not Found { "detail": "Agent not found: 'INVALID'" }Notes
-- No changes to existing successful flows
-- No additional logging or refactoring introduced
-- Change is minimal and scoped strictly to error handling
Testing
-- Verified /run returns 404 for invalid app_name
-- Verified /run_sse returns 404 for invalid app_name
-- Confirmed no regression for valid agents