Repository navigation
fix(email): list the /query routes' error statuses in the OpenAPI contract - #6910
Conversation
…tract
openapi.email.json listed only 200/422 for /query, /query/{run_id}/cancel and /query/{run_id}/respond, though they return 400/404/409/500/502. Declare them on the routes, regenerate openapi.email.json and specification.html, and add a test that every status a /query handler raises is documented.
Closes amd#4429
|
Verdict: Approve The email agent's published API contract now lists the errors its three Real-world evidenceN/A here: no evidence bundle was produced for this run. The PR description includes real requests through the mounted routers: cancel and respond return 404, and 🔍 Technical detailsIssues found 🟢 The guard test only sees statuses raised directly in the handler ( Checked
Strengths
|
Summary
openapi.email.jsonlisted only 200 and 422 for the three/queryroutes, although they also return 400, 404, 409, 500 and 502. This PR declares those statuses on the route decorators, regeneratesopenapi.email.jsonandspecification.html, and adds a test that fails if a/queryroute raises a status the spec doesn't list.Why
openapi.email.jsonis the contract the npm client and generated clients are built from. A client generated from it had no typed path for a staleneeds_inputanswer (409), a busy session (409), or an agent that failed to start (502), even thoughnpm/SPEC.mdalready documents them in prose. This is the last item of #4429; the docs part landed in #6879.Linked issue
Closes #4429
Changes
query_routes.py:POST /v1/email/querydeclares 400, 409, 500 and 502 next to its SSE 200;/query/{run_id}/canceldeclares 404;/query/{run_id}/responddeclares 404 and 409. Each description says when that status is returned. No handler logic changed.openapi.email.json: regenerated withpython -m gaia_agent_email.export_openapi.spec_html.py/specification.html: the/queryblock is hand-written and listed no errors, so it gets one paragraph naming them (cancel and respond already did); regenerated withpython -m gaia_agent_email.spec_html.tests/test_rest_contract.py:test_query_routes_document_every_status_they_raisereads everyHTTPException(status_code=...)in each/queryhandler from the source and asserts the spec lists it, so a new status added without aresponsesentry fails CI.CHANGELOG.md: an Unreleased "Fixed" entry.SCHEMA_VERSIONbump: no request or response shape changed and no operation was added. I followed fix(email): declare the sidecar bearer gate in the OpenAPI contract #3002, which also only added to what the OpenAPI document declares and did not bump. Happy to bump to 2.16 if you'd rather treat this as a contract change.Test plan
python -m gaia_agent_email.export_openapi --checkandpython -m gaia_agent_email.spec_html --checkboth report up to date after regenerating (the OpenAPI check failed before).pytest hub/agents/email/python/tests tests/test_email_openapi_conformance.py: 2378 passed, 3 skipped (Python 3.12,.[dev,api,publish]+ the email package, as intest_email_agent_unit.yml)./respond's responses on purpose: the new test failed withPOST /v1/email/query/{run_id}/respond raises ['409'] undocumented, then passed again once restored.python util/lint.py --all: everything passes except two Pylint E1120 errors insrc/gaia/utils/awake_clock.py:47andsrc/gaia/utils/terminal.py:109, files this PR doesn't touch.Evidence
export_openapi.build_app()in aTestClient), next to what the regenerated spec now lists:Before this PR, all three listed only
['200', '422'].Checklist
Closes #N/Fixes #N/Refs #N).python util/lint.py --all,pytest tests/unit/).