fix(backend-monitor): accept model as a query parameter#9411
Open
Dennisadira wants to merge 1 commit intomudler:masterfrom
Open
fix(backend-monitor): accept model as a query parameter#9411Dennisadira wants to merge 1 commit intomudler:masterfrom
Dennisadira wants to merge 1 commit intomudler:masterfrom
Conversation
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>
70d8b6c to
e201e94
Compare
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.
Description
This PR fixes #9207.
The
/backend/monitorendpoint is routed asGETbut 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@Paramannotation accordingly. Returns 400 when no model is provided.docs/content/features/backend-monitor.md— document the query-parameter form and update thecurlexample.swagger/*— regenerated viamake protogen-go && make swagger(no hand edits).To keep this non-breaking, the handler falls back to binding the request body when the
modelquery 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/shutdownendpoint is left untouched — as the issue notes, it correctly uses a body per REST conventions.Notes for Reviewers
curl "http://localhost:8080/backend/monitor?model=<name>"and with the legacy body form to confirm backwards compatibility./v1/backend/monitorand/v1/backend/shutdownare 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