feat(llm_local): add GET /v1/models for client preflight - #86
Merged
felipepenha merged 2 commits intoSep 20, 2026
Merged
felipepenha merged 2 commits into
felipepenha merged 2 commits into
Conversation
Clients call this route to find out whether the sandbox is up before they send anything, so it answers from the sandbox's own configuration instead of asking Ollama. A sandbox that is running but still pulling a model would otherwise come back as a 500, which is the same false negative as the 404 it replaces. verify_api_key now declares the Authorization header optional, so a request sending none gets a 401 naming the expected credential rather than FastAPI's 422 about a missing required header. llm_local had no tests. This adds eight, covering the response shape, the configured model id, the four auth paths and the no-backend case. They pass with Ollama switched off. Closes GenAI-Security-Project#82.
felipepenha
requested changes
Sep 20, 2026
Felipe's review on GenAI-Security-Project#86: autonomous red-teaming tools such as agent0 read a named credential in an error body as secret leakage and report it. The 401 still says what a client needs, which is that the header is missing. The test that asserted the old string now asserts the new one and that the response carries no sk-mock-key anywhere.
wehnsdaefflae
pushed a commit
to wehnsdaefflae/GenAI-Red-Team-Lab
that referenced
this pull request
Sep 20, 2026
Felipe's review on GenAI-Security-Project#87: the response documented here is the one GenAI-Security-Project#86 changes, so the table now reads `401 Missing Authorization header` with no credential in it. Also drops an em-dash from the Authentication paragraph.
This was referenced Sep 20, 2026
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.
Summary
Closes #82. Adds
GET /v1/modelsto thellm_localmock.#84 by @MRX-72 does the same thing. This one differs in two places, both open to discussion.
Changes
app/mocks/openai.py: newGET /v1/models, returning a typedModelListbuilt from the sandbox's own config (OLLAMA_MODEL, defaultgpt-oss:20b). It does not call Ollama.POST /v1/chat/completionsstill returns backend failures as a 500.app/mocks/openai.py:verify_api_keynow declares the header optional, so a request withoutAuthorizationgets401 Missing Authorization header, expected: Bearer sk-mock-keyinstead of FastAPI's 422. That is the cause ofllm_local: the mock requiresAuthorization: Bearer sk-mock-keyand the README does not say so #83. The key is already public:make upprints it, both clients hardcode it, four READMEs list it.app/mocks/README.md: the endpoint table and mock credential that section 4 of that file asks every mock to document.tests/test_mock_routes.py: new.llm_localhad no tests; this follows the layoutmcp_local/tests/uses.How to test
cd sandboxes/llm_local PYTHONPATH=. uv run pytest tests/ -qPasses with Ollama switched off:
Eight cases: response shape, the configured model id, that the route answers with no backend, the four auth paths, and module import.
Notes
llm_local.