Skip to content

fix(backend-monitor): accept model as a query parameter#9411

Open
Dennisadira wants to merge 1 commit intomudler:masterfrom
Dennisadira:fix/backend-monitor-query-param
Open

fix(backend-monitor): accept model as a query parameter#9411
Dennisadira wants to merge 1 commit intomudler:masterfrom
Dennisadira:fix/backend-monitor-query-param

Conversation

@Dennisadira
Copy link
Copy Markdown

Description

This PR fixes #9207.

The /backend/monitor endpoint is routed as GET but its handler bound the model name from a request body, which is invalid per REST and breaks Swagger UI and OpenAPI codegen tools that refuse to send a body with GET (the issue reporter hit this while building a Home Assistant integration).

Changes:

  • core/http/endpoints/localai/backend_monitor.go — read ?model=<name> from the query string; update the Swagger @Param annotation accordingly. Returns 400 when no model is provided.
  • docs/content/features/backend-monitor.md — document the query-parameter form and update the curl example.
  • swagger/* — regenerated via make protogen-go && make swagger (no hand edits).

To keep this non-breaking, the handler falls back to binding the request body when the model query parameter is empty, so existing clients sending {"model": "..."} with GET continue to work. Happy to drop the fallback and make it a clean break if you'd prefer that.

The POST /backend/shutdown endpoint is left untouched — as the issue notes, it correctly uses a body per REST conventions.

Notes for Reviewers

  • Manually verified with curl "http://localhost:8080/backend/monitor?model=<name>" and with the legacy body form to confirm backwards compatibility.
  • Swagger files are machine-generated from the annotation; not hand-edited.
  • Side note unrelated to this PR: /v1/backend/monitor and /v1/backend/shutdown are registered in the router but don't appear in the Swagger spec. Happy to file a follow-up issue if that's useful.

Signed commits

  • Yes, I signed my commits.

The /backend/monitor endpoint is routed as GET but its handler bound the
model name from a request body, which is invalid per REST and breaks
Swagger UI and OpenAPI codegen tools that refuse to send bodies with GET.

Switch to reading ?model=<name> as a query parameter and update the
Swagger annotation, regenerated spec files, and documentation. The
handler still falls back to body binding when the query parameter is
absent, so existing clients sending {"model": "..."} continue to work.

Fixes mudler#9207

Signed-off-by: Adira Denis Muhando <dennisadira@gmail.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.

/backend/monitor GET endpoint incorrectly requires body parameter (Swagger/docs and implementation do not match REST standards)

1 participant