Repository navigation
fix(voip): correct /voip/call path param so outbound calls don't 422 (#1069) - #1071
Merged
Merged
Conversation
…1069) POST /api/agents/{agent_name}/voip/call declared its agent path parameter via the AuthorizedAgent dependency, whose Path() parameter is named `name`. The route template exposes the segment as `{agent_name}` (matching the sibling GET/PUT/DELETE /voip handlers, which use the *_by_name dependency family), so FastAPI derived a required path param `name` that no URL could populate — every call, REST and the call_user MCP tool that proxies to it, failed with HTTP 422 (loc: ["path","name"]). Swap the handler to AuthorizedAgentByName (Path param `agent_name`, an identical access check — both call db.can_user_access_agent) so the dependency's path parameter matches the template. No auth boundary change. The MCP client already targets the correct URL, so no MCP-side change. Add tests/unit/test_1069_voip_call_path_param.py: loads the real voip router with the real dependencies module (leaf services stubbed) and asserts FastAPI's flattened dependant for the POST route carries `agent_name`, not `name` — mutation-verified against a revert. The loader manually saves/restores only the sys.modules keys it touches (not patch.dict, which clears+restores all of sys.modules and would wipe the real jose/cryptography imports, breaking later JWT tests). Fixes #1069 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The voip-telephony flow doc named the outbound-trigger dependency as AuthorizedAgent in two explicit spots (Entry Points + Security table). PR #1071 swapped the handler to AuthorizedAgentByName to fix the {agent_name} path-param mismatch, so update the doc to match. The {name} URL placeholders are doc-wide generic shorthand and are left as-is. No index change (bug fix, no new flow or name/description change). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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
POST /api/agents/{agent_name}/voip/callreturned HTTP 422 on every call (REST and thecall_userMCP tool). The handler declared its agent path param via theAuthorizedAgentdependency, whosePath()param is namedname— but the route template exposes the segment as{agent_name}, so FastAPI required anamepath param that no URL could fill (loc: ["path","name"]).AuthorizedAgentByName(Path paramagent_name), matching the route template and the sibling GET/PUT/DELETE/voiphandlers. The two dependencies perform an identical access check (db.can_user_access_agent) — only the path-param name differs, so there is no auth boundary change.client.ts) already targets the correct URL, so no MCP-side change is needed (Invariant feat: SMARTS trading pipeline with Telegram notifications and Miro visualization #13 satisfied).Changes
src/backend/routers/voip.py—AuthorizedAgent→AuthorizedAgentByName(import + POST handler); fixed stale{name}→{agent_name}in the module docstring.tests/unit/test_1069_voip_call_path_param.py(new) — loads the real voip router with the realdependenciesmodule (leaf services stubbed) and asserts FastAPI's flattened dependant for the POST route carriesagent_name, notname. Plus a dependency-contract test pinning why the fix works.Root cause
GET/PUT/DELETE /api/agents/{agent_name}/voip{agent_name}agent_name✅ (OwnedAgentByName)POST /api/agents/{agent_name}/voip/call{agent_name}name❌ (AuthorizedAgent)Test Plan
AuthorizedAgentmakes the route-level test fail (assert 'agent_name' in {'name'}).fakeredis-missing collection error intest_dispatch_breaker.py, unrelated to this change).sys.moduleskeys it touches — does not poison sibling JWT tests (test_voice_auth,test_websocket_auth).Fixes #1069
🤖 Generated with Claude Code