Skip to content

Unhandled exception for invalid app_name leads to 500 response #5374

@AbhishekMauryaGEEK

Description

@AbhishekMauryaGEEK

Describe the Bug:
When an invalid app_name is provided to API endpoints such as /run and /apps/{app_name}/app-info, the backend raises a ValueError from load_agent, which is not handled at the API layer. This results in a 500 Internal Server Error instead of a controlled client error.


Steps to Reproduce:

  1. Install the project and start the API server:
    python -m google.adk.cli api_server
    

Send a request with an invalid app_name:

curl -X POST http://127.0.0.1:8000/run \
-H "Content-Type: application/json" \
-d '{
 "app_name": "INVALID",
 "user_id": "u1",
 "session_id": "s1",
 "message": "hello"
}'

Observe the response and server logs.

Expected Behavior:
The API should return a controlled client error (e.g., 404 Not Found or 400 Bad Request) for invalid app_name values.

Observed Behavior:
The server returns:

HTTP/1.1 500 Internal Server Error

Server logs show:

ValueError: Agent not found: 'INVALID'

Environment Details:

ADK Library Version (pip show google-adk): N/A (tested from source)
Desktop OS: Windows
Python Version (python -V): 3.11

Model Information:

Are you using LiteLLM: No
Which model is being used: N/A
🟡 Optional Information

Regression:
Not tested.

Logs:

ValueError: Agent not found: 'INVALID'

Screenshots / Video:
N/A

Additional Context:
The issue appears to originate from unhandled exceptions in load_agent(app_name) propagating to the API layer without validation or proper error handling.

Minimal Reproduction Code:

Not applicable (reproducible via API request)

How often has this issue occurred?:

Always (100%)


This will render exactly like your screenshot UI expects

Metadata

Metadata

Labels

web[Component] This issue will be transferred to adk-web

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions