fix(safety): retain query confirmation without configured AI - #742
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
The behaviour is right for the case #703 describes, and your two new cases do fail against the pre-change source, so the guard is pinned rather than decorative. One thing needs narrowing before this can land.
Please key the silence on the unconfigured case alone, for example a distinct code emitted only when the provider has no credentials at all, and leave the rest of Also |
|
Fixed in 415fc4d. Missing required credentials now carry a distinct The regression cases cover invalid provider names, missing models, missing custom URLs and Ollama's model-not-found response, plus the absent-key confirmation and real validation-to-HTTP mapping. Six UI cases and both credential mapping cases fail on the previous implementation. Current targeted validation is 121 component, 55 unit and 9 API tests, all passing, plus the repository's static checks and both builds. The PR body records the commands and local full-suite limitations. |
…hed setup Silencing every missing-credentials error hid a real case. LLM_PROVIDER set without LLM_API_KEY looked exactly like no AI at all, while the same omission for ollama or custom stayed visible, so the same mistake was reported for two providers and swallowed for the other two. Naming a provider is a statement of intent to use AI, so LLMConfig now carries providerExplicit, resolveConfig sets it from the environment or an override, and unconfiguredReason is the single place that decides which of the two cases a missing credential is. Also pins the gemini and openai reason, which no test covered: dropping the argument left the suite green.
Description
When a provider has no required API key, Query Safety Check keeps a plain confirmation explaining that the statement may change data, objects or permissions. A distinct
LLM_UNCONFIGUREDcode selects this path. Invalid provider/model/URL settings retainLLM_CONFIGand remain visible, as do authentication and service errors.Closes #703.
Type of Change
Changes Made
LLM_UNCONFIGURED, retaining HTTP 503 and the existing error response shape; no message matching is used.docs/FEATURES.mdwith the narrower missing-credentials exception, and list the new response code indocs/API_DOCS.md.Testing
bun run test:components --pass-with-no-tests -t 'QuerySafetyDialog|isDangerousQuery': 121 matching tests passed, 0 failed.bun run test:unit --isolate --pass-with-no-tests -t 'createErrorResponse|ApiErrorCode|BaseLLMProvider|validateConfig': 55 passed, 0 failed.bun run test:api --isolate --pass-with-no-tests -t 'POST /api/ai/query-safety': 9 passed, 0 failed.LLM_AUTHand other failure paths remain visible.format,lint,typecheck,knip,readme:check,chart:check,channels:showcase:check,security:check, productionbuild,build:libandattw.bun run test/ coverage and E2E were not completed: Windows host lacks Helm/chart dependencies, Docker is unavailable, and existing SQLite cleanup tests encounter Windows file-lock errors. Official Linux CI must verify the full suite and 100% line-coverage gate.Environment: Windows, Node.js 24.18.1, Bun 1.4.2. Both builds ran from a clean checkout of implementation commit 415fc4d with real local dependencies. The subsequent API documentation entry passed
readme:check; CI validates the final submitted commit.Checklist
Additional Notes
AI-assisted implementation and test execution using Codex. Existing LLMConfigError callers without a reason retain
LLM_CONFIG; only errors explicitly tagged as missing credentials use the new code. No new dependencies or environment variables. All existing error messages and HTTP statuses are retained.