Skip to content

[Bug]: Conversation runtime routes return 404 without declaring it in the OpenAPI schema #6494

Open

Description

@enyst

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

GET /api/conversations/{conversation_id}/runtime raises 404 for an unknown conversation (conversation_router.py#L237-L245),`` and POST /api/conversations/{conversation_id}/runtime/reprovision delegates to it (#L254-L262).```` Neither declares `responses={404: …}`, so the OpenAPI document lists only 200 and 422 for both. Other routes in the same router declare their 404, for example `pause` (#L367).`````

The impact is small but real: generated clients, such as the one mirrored in clients/typescript/, and Schemathesis status-code conformance checks treat the 404 as unexpected.

Expected Behavior

Both routes declare 404 in their OpenAPI responses.

Actual Behavior

The responses for both routes are ['200', '422'].

Steps to Reproduce

Run the code sample below on main (28f4dfe).

Acceptance Criteria

  • Both routes declare their 404 response.
  • Optional: a test that checks every /{conversation_id} route answers an unknown id only with codes it declares, so new routes can't drift.

SDK Version

main at 28f4dfe

Python Version

3.13

Operating System

Linux

Minimal Code Sample

from fastapi import FastAPI
from openhands.agent_server.conversation_router import conversation_router

app = FastAPI()
app.include_router(conversation_router, prefix="/api")
paths = app.openapi()["paths"]
print(sorted(paths["/api/conversations/{conversation_id}/runtime"]["get"]["responses"]))               # ['200', '422']
print(sorted(paths["/api/conversations/{conversation_id}/runtime/reprovision"]["post"]["responses"]))  # ['200', '422']
print(sorted(paths["/api/conversations/{conversation_id}/pause"]["post"]["responses"]))                # ['200', '404', '422']

Evidence and Additional Context

Found by a Hypothesis test over every /{conversation_id} route: for an unknown id, the answer is never 5xx and is always a declared status. On the parents of e98b956 (#5819) and 6d65010 (#5814) the same test also finds the 500 and undeclared-400 cases those PRs fixed. See #6486.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Verified against main (28f4dfe): GET /api/conversations/{conversation_id}/runtime (openhands-agent-server/openhands/agent_server/conversation_router.py L237-L245) raises HTTPException(404) for an unknown conversation, POST .../runtime/reprovision (L254-L262) delegates to it, and neither declares responses={404: ...}, so the OpenAPI lists only 200 and 422. Sibling routes in the same router (pause, interrupt, delete, secrets, ...) already declare the 404, so the fix follows an established repository convention and needs no design decision.

Bounded scope: declare the 404 response on these two routes only, matching the sibling-route convention. Non-goals: no change to route behavior or status codes; no TypeScript client regeneration (clients/typescript/ mirrors 200-response schemas, which are unchanged, so generated types are unaffected and release-time schema sync remains the existing mechanism); no generic OpenAPI drift-test framework (the issue's optional criterion).

Priority rationale: the finding comes from a property-based (Hypothesis) test, not a user report, support evidence, or production impact, so it stays priority:low under the triage policy.

Acceptance Criteria

  • app.openapi()["paths"]["/api/conversations/{conversation_id}/runtime"]["get"]["responses"] includes a 404 entry, and the same holds for ["/api/conversations/{conversation_id}/runtime/reprovision"]["post"]["responses"] - the issue's code sample prints ['200', '404', '422'] for both routes.
  • The declaration matches actual behavior: with an unknown conversation id, both routes respond exactly 404, as already exercised by tests/agent_server/test_conversation_router.py::test_runtime_requires_existing_conversation.
  • The OpenAPI change is additive only: no existing path, method, response status, or component schema is removed or changed (e.g. a diff of serialize_openapi(build_public_openapi()) against main, or the agent-server-rest-api-breakage oasdiff check, shows no removals).

Activity

  1. added
    bug
    on Nov 5, 2026
  2. added
    ready-for-dev
    on Nov 5, 2026
  3. samarAli-7 commented on Nov 5, 2026

    @samarAli-7

    Hi, I'd like to pick this up.

    Reproduced on main (28f4dfe): GET /api/conversations/{conversation_id}/runtime and POST /api/conversations/{conversation_id}/runtime/reprovision both advertise ['200', '422'], while POST /api/conversations/{conversation_id}/pause advertises ['200', '404', '422'].

    Plan:

    • Add responses={404: {"description": "Conversation not found"}} to both decorators, no behavior or status code change.
    • Add a contract test asserting both operations declare 404 in app.openapi().
    • Run pytest tests/agent_server/test_conversation_router.py -k runtime and make test-server-schema.

    I'll open the PR once the checks pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions