Skip to content

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

@loryanstrant

Description

@loryanstrant

Describe the bug

The /backend/monitor API endpoint currently returns an error or confusion because Swagger (OpenAPI spec) and documentation indicate that a request body is required, but the HTTP method is GET — which, by REST and OpenAPI standards, must NOT have a body. This makes the endpoint:

  • Not work with standard HTTP clients and code generation tools
  • Breaks Swagger UI and OpenAPI codegen
  • Causes documentation and UX confusion
  • Technically invalid per REST standards

File: core/http/endpoints/localai/backend_monitor.go

To Reproduce

  • Visit Swagger UI or try to call /backend/monitor as GET with a body (not supported by many clients)
  • See docs: backend-monitor.md shows curl -d with GET, also invalid

Expected behavior

  • The model to monitor should be passed as a query parameter, not a body, e.g.: /backend/monitor?model=name
  • Swagger/OpenAPI spec should mark model as a query param, not a body param
  • Documentation and example cURL should reflect correct REST usage

Suggestions for the fix

  1. Update Swagger annotation in [backend_monitor.go]
    • Change from:
      // @Param request body schema.BackendMonitorRequest true "Backend statistics request"
      to:
      // @Param model query string true "Model name to monitor"
  2. Update handler implementation:
    • Instead of c.Bind(input), use input.Model = c.QueryParam("model") for clarity.
  3. Update docs:
    • Change documentation and curl example to:
      curl "http://localhost:8080/backend/monitor?model=my-model"
  4. (Optional): Consider failing with a clear error if model param is missing, and update OpenAPI/swag as well as tests.

Additional context

  • This will improve REST standards conformance, client interop, and user experience.
  • Note: The POST /backend/shutdown is fine as it properly uses a body per REST conventions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions