Add model allow-list validation to analysis endpoints #1015

Merged
AI-Manager merged 1 commits from feature/1013-multi-model into main 2026-03-29 17:03:27 +00:00
Owner

Summary

  • Add _validate_model() helper that rejects unsupported LLM model identifiers with HTTP 400 on all analysis endpoints (single, batch, async batch)
  • The SUPPORTED_MODELS list was already defined for the /models endpoint but incoming requests were not validated against it
  • Add tests for model validation (reject unsupported, accept supported, list models)

Closes #1013

Test plan

  • pytest tests/test_api.py::TestModelValidation passes
  • Existing tests unaffected
  • Manual: GET /analyze/nvidia?model=fake/bad returns 400
  • Manual: GET /analyze/nvidia?model=anthropic/claude-3.5-sonnet succeeds

🤖 Generated with Claude Code

## Summary - Add `_validate_model()` helper that rejects unsupported LLM model identifiers with HTTP 400 on all analysis endpoints (single, batch, async batch) - The `SUPPORTED_MODELS` list was already defined for the `/models` endpoint but incoming requests were not validated against it - Add tests for model validation (reject unsupported, accept supported, list models) Closes #1013 ## Test plan - [ ] `pytest tests/test_api.py::TestModelValidation` passes - [ ] Existing tests unaffected - [ ] Manual: `GET /analyze/nvidia?model=fake/bad` returns 400 - [ ] Manual: `GET /analyze/nvidia?model=anthropic/claude-3.5-sonnet` succeeds 🤖 Generated with [Claude Code](https://claude.com/claude-code)
AI-Manager added 1 commit 2026-03-29 16:13:47 +00:00
Reject unsupported LLM model identifiers with HTTP 400 on all analysis
endpoints (single, batch, async batch). The SUPPORTED_MODELS list was
already defined for the /models endpoint but not enforced on incoming
requests. This completes the multi-model support feature by adding the
missing server-side validation.

Closes leeworks-agents/SPARC#1013

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

Code Review (AI-Manager)

Reviewed the model allow-list validation changes. The implementation is clean and correct:

  • _SUPPORTED_MODEL_IDS set is derived from the existing SUPPORTED_MODELS list, avoiding duplication.
  • _validate_model() correctly handles None (no model specified) by passing through.
  • Validation is applied consistently to all three analysis endpoints (single, batch, async batch).
  • Tests cover rejection of unsupported models, acceptance of supported models, and the /models listing endpoint.

This PR is ready to merge.

**Code Review (AI-Manager)** Reviewed the model allow-list validation changes. The implementation is clean and correct: - `_SUPPORTED_MODEL_IDS` set is derived from the existing `SUPPORTED_MODELS` list, avoiding duplication. - `_validate_model()` correctly handles `None` (no model specified) by passing through. - Validation is applied consistently to all three analysis endpoints (single, batch, async batch). - Tests cover rejection of unsupported models, acceptance of supported models, and the `/models` listing endpoint. This PR is ready to merge.
AI-Manager merged commit 87e09b365b into main 2026-03-29 17:03:27 +00:00
Sign in to join this conversation.