Skip to content

fix: return a dict instead of a str on error branches - #33

Open
TeeJS wants to merge 1 commit into
effytech:mainfrom
TeeJS:fix/dict-error-returns
Open

TeeJS wants to merge 1 commit into
effytech:mainfrom
TeeJS:fix/dict-error-returns

Conversation

@TeeJS

@TeeJS TeeJS commented Aug 19, 2026

Copy link
Copy Markdown

Problem

Eleven tools are declared -> Dict[str, Any] but return a bare f-string on the non-200 branch, e.g.:

async def get_agent(agent_id:int)-> Dict[str, Any]:
    ...
    if status_code == 200:
        return response.json()
    else:
        return f"Cannot fetch requester from the freshservice ${response.json()}"

Two issues on that error line:

  1. Type-contract violation — the tool promises Dict[str, Any] but returns a str. Under recent MCP/FastMCP versions this trips structured-output validation (the same class of problem fixed for get_ticket_by_id in fix: resolve MCP output schema validation error for get_ticket_by_id #28).
  2. Literal-$ typo${response.json()} is JS-style interpolation; in a Python f-string the $ is literal, so the message renders as Cannot fetch agents ${...}.

Fix

Switch these error branches to the dict idiom already used elsewhere in the same file (e.g. get_ticket_tasks):

return {"error": "Cannot fetch requester from the freshservice", "details": response.json()}

Affected tools: update_ticket_conversation, list_all_ticket_conversation, get_products_by_id, get_requester_id, list_all_requester_fields, get_agent, update_agent, get_agent_fields, get_all_agent_groups, getAgentGroupById, get_requester_groups_by_id.

No behavior change on the success path; only the error branch return shape changes.

🤖 Generated with Claude Code

Eleven tools are declared `-> Dict[str, Any]` but return a bare f-string on the
non-200 branch, and each carries a literal-$ typo (`${response.json()}`), so the
error text renders as e.g. `Cannot fetch agents ${...}` and the return value
violates the declared type (which also trips FastMCP structured-output
validation). Switch them to the dict error idiom already used elsewhere in the
file (e.g. get_ticket_tasks): {"error": <msg>, "details": response.json()}.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant