fix: page route declares its response class so the host's /openapi.json builds - #5
Merged
Conversation
…pi.json builds The page route was annotated `-> HTMLResponse` with HTMLResponse imported inside the router-builder function, under `from __future__ import annotations`. FastAPI resolves that string against the module's globals, can't, and infers a response model from an unresolved forward reference, which pydantic refuses when the schema is built. One such route takes the host's whole /openapi.json (and /docs) down: found in QA of protoAgent v0.164.0 on the desktop app, where it answered 500 on every agent running this plugin. The route now declares `response_class=HTMLResponse` and has no return annotation. A new test builds the schema with the plugin's routers mounted; it fails before the change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F2V6GRejF7mNukAoYjj2Av
There was a problem hiding this comment.
QA panel review — PASS
code-review · head 0d8662a877bb · formal
The change is low-risk: it relies on PEP 563 (from __future__ import annotations) and function-local imports, both well-established Python mechanisms. No findings survived the panel or verification pass, so there is nothing to fix first. The panel did not disagree on any point. One coverage gap: the verifier could not independently confirm the PEP 563 mechanism or test-pattern fit because the repo returned 404 on both the specified and default URLs — this is a verification gap, not a refutation, and the diff is internally consistent.
No findings — the review came back clean.
findings JSON (machine-readable)
[]
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.
The page route was annotated
-> HTMLResponsewith the import inside the router builder, under postponed annotations. FastAPI cannot resolve the string, and pydantic refuses the resulting forward reference when the schema is built. One such route makes the host's whole/openapi.json(and/docs) answer 500. Found in QA of protoAgent v0.164.0 on the desktop app.Fix: declare
response_class=HTMLResponseon the decorator and drop the return annotation.Test: builds the schema with the plugin's routers mounted. It fails before the change and passes after.
ruff check,ruff format --checkandpytest -qare green.The host is also getting a guard (protoAgent PR, same QA pass): a plugin route whose schema cannot be built is left out of the schema with a warning, instead of taking it down.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F2V6GRejF7mNukAoYjj2Av