Skip to content

fix: page route declares its response class so the host's /openapi.json builds - #5

Merged
mabry1985 merged 1 commit into
mainfrom
fix/view-openapi
Sep 11, 2026
Merged

fix: page route declares its response class so the host's /openapi.json builds#5
mabry1985 merged 1 commit into
mainfrom
fix/view-openapi

Conversation

@mabry1985

Copy link
Copy Markdown
Member

The page route was annotated -> HTMLResponse with 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=HTMLResponse on 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 --check and pytest -q are 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

…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

@protoreview protoreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
[]

@protoreview protoreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promoting the PASS verdict for head 0d8662a877bb: all checks terminal-green, zero unresolved review threads. (approve-on-green)

@mabry1985
mabry1985 merged commit d564473 into main Sep 11, 2026
3 checks passed
@mabry1985
mabry1985 deleted the fix/view-openapi branch September 11, 2026 18:30
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