Conversation
There was a problem hiding this comment.
Code Review
This pull request modularizes the provider validation logic by splitting it into separate files under src/lib/providers/validation/ (including core.ts, enterprise.ts, search.ts, specialty.ts, standard.ts, utils.ts, and web.ts) and re-exporting them via index.ts. The review feedback highlights three key issues: the isLocal flag is not passed to specialty validators in core.ts (which can break local/private network deployments), a try-catch block in validateAzureOpenAIProvider prematurely returns on error and prevents probe fallbacks, and crypto is used globally in web.ts without an explicit import, potentially causing compatibility issues in older Node.js environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (SPECIALTY_VALIDATORS[provider]) { | ||
| try { | ||
| return await SPECIALTY_VALIDATORS[provider]({ apiKey, providerSpecificData }); | ||
| } catch (error: any) { | ||
| return toValidationErrorResult(error); | ||
| } | ||
| } |
There was a problem hiding this comment.
The isLocal flag is determined from the provider at the beginning of validateProviderApiKey but is never passed to any of the SPECIALTY_VALIDATORS. Consequently, specialty and enterprise validators (such as Databricks, Azure OpenAI, Snowflake, etc.) do not receive isLocal and default to false when calling validationRead or validationWrite. This causes local or private network deployments of these services to fail validation because the outbound URL guard blocks private IP ranges and proxy fallback is incorrectly attempted.
| if (SPECIALTY_VALIDATORS[provider]) { | |
| try { | |
| return await SPECIALTY_VALIDATORS[provider]({ apiKey, providerSpecificData }); | |
| } catch (error: any) { | |
| return toValidationErrorResult(error); | |
| } | |
| } | |
| if (SPECIALTY_VALIDATORS[provider]) { | |
| try { | |
| return await SPECIALTY_VALIDATORS[provider]({ apiKey, providerSpecificData, isLocal }); | |
| } catch (error: any) { | |
| return toValidationErrorResult(error); | |
| } | |
| } |
| for (const probeUrl of [ | ||
| `${baseUrl}/openai/deployments?api-version=${encodedVersion}`, | ||
| `${baseUrl}/openai/models?api-version=${encodedVersion}`, | ||
| ]) { | ||
| try { | ||
| const response = await validationRead(probeUrl, { method: "GET", headers }); | ||
| if (response.ok) { | ||
| return { valid: true, error: null, method: "azure_probe" }; | ||
| } | ||
| if (response.status === 401 || response.status === 403) { | ||
| return { valid: false, error: "Invalid API key" }; | ||
| } | ||
| if (response.status === 400 || response.status === 404 || response.status === 405) { | ||
| continue; | ||
| } | ||
| if (response.status === 429) { | ||
| return { | ||
| valid: true, | ||
| error: null, | ||
| method: "azure_probe", | ||
| warning: "Rate limited, but credentials are valid", | ||
| }; | ||
| } | ||
| if (response.status >= 500) { | ||
| return { valid: false, error: `Provider unavailable (${response.status})` }; | ||
| } | ||
| } catch (error) { | ||
| return toValidationErrorResult(error); | ||
| } | ||
| } |
There was a problem hiding this comment.
In validateAzureOpenAIProvider, the loop iterates over two probe URLs (deployments and models). However, the try-catch block inside the loop immediately returns toValidationErrorResult(error) if validationRead throws an error (e.g., due to a network timeout or endpoint-specific restriction). This prevents the loop from trying the second probe URL or falling through to the chat probe, defeating the fallback design.
for (const probeUrl of [
`${baseUrl}/openai/deployments?api-version=${encodedVersion}`,
`${baseUrl}/openai/models?api-version=${encodedVersion}`,
]) {
try {
const response = await validationRead(probeUrl, { method: "GET", headers });
if (response.ok) {
return { valid: true, error: null, method: "azure_probe" };
}
if (response.status === 401 || response.status === 403) {
return { valid: false, error: "Invalid API key" };
}
if (response.status === 400 || response.status === 404 || response.status === 405) {
continue;
}
if (response.status === 429) {
return {
valid: true,
error: null,
method: "azure_probe",
warning: "Rate limited, but credentials are valid",
};
}
if (response.status >= 500) {
return { valid: false, error: `Provider unavailable (${response.status})` };
}
} catch (error) {
// Ignore error to allow fallback to the next probe URL or chat probe
}
}| @@ -0,0 +1,1192 @@ | |||
| import { randomUUID } from "node:crypto"; | |||
There was a problem hiding this comment.
The file uses crypto.randomUUID() and crypto.getRandomValues() but only imports randomUUID from node:crypto. It does not import the crypto default export. While modern Node.js environments (v19+) expose crypto globally, older LTS versions (like Node 18) do not, which will cause a ReferenceError: crypto is not defined at runtime. It is safer and more backward-compatible to import crypto explicitly.
import crypto, { randomUUID } from "node:crypto";|
Thanks @oyi77 — blockers for the validation modularization:
|
ba5e277 to
e422979
Compare
…he-poisoning + SC2086 (diegosouzapw#3965)
Integrated into release/v3.8.27
Integrated into release/v3.8.27
Integrated into release/v3.8.27
…iegosouzapw#3954) (diegosouzapw#3995) rate_limited_until is a TEXT column, but setConnectionRateLimitUntil (Antigravity full-quota path) persists a raw epoch number that SQLite coerces to a numeric string ("1781696905131.0"). The selection predicate isAccountUnavailable then did new Date("1781696905131.0") -> NaN, so the cooling connection was never skipped and the router kept dispatching to rate-limited accounts. Normalize numeric-epoch strings (and number/Date/ISO) via a shared cooldownUntilMs() helper in isAccountUnavailable / getEarliestRateLimitedUntil / filterAvailableAccounts / parseFutureDateMs. ISO behavior preserved.
…w#3976) (diegosouzapw#3996) llm7 and byteplus carry a real modelsUrl but were not classified by any live-fetch branch of the model-import route, so their hardcoded 4-entry registry catalog was served (source local_catalog) instead of the upstream catalog. Add both to NAMED_OPENAI_STYLE_PROVIDERS so the route probes <baseUrl>/models and serves the live list, falling back to the local catalog only on fetch failure.
…mount ref (diegosouzapw#3972) (diegosouzapw#3997) The auto-refresh interval gated each tick on visibleRef, seeded once at mount and updated only by a visibilitychange event. A tab mounted while document.visibilityState is 'hidden' (background load, bfcache, embedded/proxied webviews) with no later visibilitychange left the ref false forever, so the interval ticked but never fetched — only the manual button worked. Read the live document.visibilityState in the tick instead.
…iegosouzapw#3959) (diegosouzapw#3998) strict-random shuffled only the deck-selected slot 0 and left the fallback remainder in fixed priority order, so after a failing deck pick the chain always fell through to the same top-priority model — a persistently-failing model was retried on essentially every request and fallback load never spread across peers. Shuffle the remainder too (like the random strategy).
Integrated into release/v3.8.27
…aude OAuth path (diegosouzapw#3974) (diegosouzapw#3999) The client-negotiated anthropic-beta: tool-search-tool-2025-10-19 was dropped on both Claude code paths (default executor rebuilt from static ANTHROPIC_BETA_CLAUDE_OAUTH; selectBetaFlags only read the client beta to gate thinking/effort), so claude.ai rejected deferred-tool requests with 400 'Tool reference not found'. Add an allowlist-merge (mergeClientAnthropicBeta) that unions the client's allowlisted betas into the outbound set on both paths, preserving diegosouzapw#3415 (no forced thinking/effort).
Integrated into release/v3.8.27
Integrated into release/v3.8.27
…iegosouzapw#3943) Integrated into release/v3.8.27
Integrated into release/v3.8.27
Integrated into release/v3.8.27
… qwen body-check) The qwen-web validation body-check merged in diegosouzapw#3958 pushed validation.ts past its frozen size on the integrated release tip. Bump the baseline with justification; no logic is separately extractable from the existing qwen-web validation branch.
Integrated into release/v3.8.27 — low-risk group (playwright 1.60→1.61 minor + transitive patches; fumadocs-core 16.9→16.10 minor).
…ren't empty (diegosouzapw#4001) Integrated into release/v3.8.27 — schematized diff_block parsing follow-up to diegosouzapw#3938.
… plugins (diegosouzapw#3993) Modularize provider registry (diegosouzapw#3594). Integrated into release/v3.8.27 after rebase + behavior-preservation verification (provider-consistency gate 159/232/0, typecheck, registry tests, build 556/556). Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
… modularization The provider-registry modularization (diegosouzapw#3993) was cut from a base predating the byteplus (diegosouzapw#3877) and mimocode (diegosouzapw#3837) registry entries, so merging it silently dropped both providers (getRegistryEntry returned undefined → validation reported 'not supported'). Re-add them as registry modules in the new structure; registered count 159→161, provider-consistency 161/232/0. Also align the pre-existing qwen-web validator test to diegosouzapw#3958: since the validator now requires a real `user` object in the 200 body, the mock must carry one.
Modularize validation schemas (diegosouzapw#3594). Integrated into release/v3.8.27 after rebase (reconciled the merged hiddenSidebarGroupLabels diegosouzapw#3971 + intelligenceSyncRequestSchema into the new modules) + behavior verification (typecheck, 195 schema/settings/validation tests, build 556/556). Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
…nai/codex pricing (diegosouzapw#4005) Integrated into release/v3.8.27 — openai model-discovery honors custom base URL (SSRF-guarded) + pricing rows for new openai/codex models. Tested + baselines bumped.
Integrated into release/v3.8.27 — repair LiveWS sidecar (startup, same-origin /live-ws, main→sidecar compression.completed bridge, early-msg queue). Fixed the cookie-parse regex (\s) + added a focused unit test; baseline bumped for the non-blocking chatCore bridge.
… gitignore it A worktree node_modules symlink (-> the main checkout's node_modules) was staged by a `git add -A` during the diegosouzapw#3988 merge and committed into 05213ac. The symlink points at the repo's own node_modules path, so checking it out turns the main checkout's node_modules into a self-referential symlink (breaking tsx/all node ops). Untrack it and add a root-anchored /node_modules ignore so the symlink form can't be re-committed (the existing 'node_modules/' only matches directories).
…uzapw#4014) Integrated into release/v3.8.27. Adjustments before merge: - Synced with the current release tip (was 11 commits behind). - Added the 3 LLMLingua-2 ONNX optional-runtime deps to dependency-allowlist.json (@atjsh/llmlingua-2, @tensorflow/tfjs, js-tiktoken) — the only gate that was red. - socks was allowlisted directly on release (separate fix d7db5c7; it was declared by diegosouzapw#4004 but never allowlisted, leaving check:deps red release-wide). Verified locally: check:deps OK, file-size OK, public-creds OK, provider-consistency 161/232/0, typecheck:core clean, 24/24 LLMLingua tests pass. The only remaining Fast-QG red is the pre-existing diegosouzapw#3972 orphan test (request-logger-autorefresh-visibility-3972.test.tsx), which is release-wide and unrelated to this PR.
… runner collects it tests/unit/request-logger-autorefresh-visibility-3972.test.tsx (added by diegosouzapw#3972 via diegosouzapw#3997) sat at the top level of tests/unit/ as a .tsx vitest test, which NO runner collects: the node runner only globs *.test.ts, and test:vitest:ui only runs tests/unit/ui. So the diegosouzapw#3972 regression guard never executed in CI and check:test-discovery was red release-wide. Move it under tests/unit/ui/ (the collected vitest:ui path) and fix the relative import depth. Verified: the test now runs and passes (2/2), and check:test-discovery is green.
… Lite schema fix (diegosouzapw#3952) (diegosouzapw#4018) Captures the net-new value from diegosouzapw#3960 (per-engine breakdown analytics) and diegosouzapw#3952 (Lite engine schema fix) onto release/v3.8.27. Fast QG green; 622/622 compression+analytics tests pass.
…mimocode) (diegosouzapw#4015) Real bugfix: guard model-less registry entries (mimocode) in getUnsupportedParams so handleChatCore no longer throws 'entry.models is not iterable' / reports 'All models failed' for unrelated requests. Includes a regression test. Fast QG green.
…AST-smoke, mutation infra) (diegosouzapw#4016) * docs(ops): add quality-gate assessment + replication playbook (Fase 9 foundation) * feat(ci): flip oasdiff breaking-change gate to blocking (ratchet) * docs(ops): deliver main branch-protection ruleset for owner to apply * fix(ci): run typecheck:core in PR->release fast-gates (close fast-gates hole, part 1) * perf(mutation): enable Stryker incremental mode + cache (scales the 60/80 rollout) * feat(ci): commit CodeQL advanced config (security-extended), replacing default-setup * feat(ci): version semgrep SAST workflow (owasp/secrets), advisory * feat(quality): TIA test-impact map builder (import-graph; map built at runtime, gitignored) * feat(quality): TIA impacted-test selector with run-all fail-safe * fix(ci): run TIA-impacted unit tests in PR->release fast-gates (build map at runtime, fail-safe full) * feat(ci): DAST-smoke per-PR (schemathesis subset + promptfoo injection-guard, blocking) * fix(ci): unbreak Fase 9 PR CI (MDX frontmatter, CodeQL conflict, dast-smoke advisory) - Add MDX frontmatter to docs/ops/{BRANCH_PROTECTION_MAIN,QUALITY_GATE_PLAYBOOK}.md. fumadocs rejects frontmatter-less docs -> 'npm run build' failed -> broke dast-smoke's build step (the release fast-gates never runs build, so this only surfaced on the PR). - codeql.yml: workflow_dispatch-only until the owner switches repo CodeQL Default->Advanced (advanced configs cannot be processed while default setup is enabled; documented inline). - dast-smoke.yml: job-level continue-on-error (advisory) so this brand-new gate matures before it blocks (repo convention: advisory -> blocking). * ci(quality): make TIA unit-test step advisory until release test-debt is cleared release/v3.8.27 carries ~17 pre-existing failing unit tests (budget diegosouzapw#3537, apiKey this PR — the new 'run tests on PR->release' gate surfaced them. Per the repo's advisory->blocking convention, this step enters advisory (it still runs + reports) so pre-existing debt doesn't block the gate program. typecheck:core stays blocking. Flip to blocking (remove continue-on-error) once the release suite is green.
…_uses) (diegosouzapw#4021) Opt-in Claude-only delegated compression: injects context_management.clear_tool_uses_20250919 at the Claude pre-serialization chokepoint (composes with clear_thinking, thinking first), threaded via ExecuteInput from handleChatCore. Pure edit-builder + 11 tests (7 unit + 4 e2e fetch-capture). Beta context-management-2025-06-27 already advertised; allowlist done. Telemetry/400-fallback/claude-web coverage deferred.
…iegosouzapw#4024) randomUUID non-HTTPS fallback + static CompareTab import; raw HTTP TRACE->405 method guard wired into dev + standalone servers. Integrated into release/v3.8.27.
…pw#4020) Presentation/relabel refactor of the Settings dashboard (API Manager -> API Keys), card relocations, Toggle adoption, present-but-disabled engine steps. Auth-file changes are string/comment-only (no behavior change). Integrated into release/v3.8.27.
…rizations (diegosouzapw#4030) Restores schema fields (combo reasoningTokenBuffer, budget-0 diegosouzapw#3537, openrouter preset, proxy family diegosouzapw#3777, resilience degradation/providerCooldown), qwen-web v2 endpoint+catalog, mimocode models key — all dropped by diegosouzapw#3988/diegosouzapw#3993 — and aligns 3 tests to diegosouzapw#3941/diegosouzapw#3993. Verified: 8 failing regression tests on release tip -> 131/131 green on this branch. Integrated into release/v3.8.27.
- Splits the monolithic provider validation file into 7 domain-specific files - Extracts Enterprise, Web, Search, Standard, Specialty, and Utils into dedicated modules - Uses folder-as-module pattern with index.ts facade for zero backward-compatibility breakages - Auto-prunes and manages all imports for strict typechecking
|
Thanks for all the modularization work here, @oyi77 🙏. We've decided to hold the per-module "non-stacked" refactors and run the decomposition as one coordinated pass after the in-flight quality-gate work lands, instead of merging them piecemeal. Reason: on the two we did merge (#3993, #3988) we caught logic being dropped during the move — and the gates (provider-consistency / typecheck) don't detect internal-logic loss — so each of these needs a full lossless audit, which isn't tractable across many overlapping PRs against a moving release branch right now. The coordinated modularization is tracked in #3501 / #3594; we'd genuinely value your input on that plan once it's up. Closing for now — purely sequencing, not a reflection on the effort. |
… modules (diegosouzapw#3990) Split src/lib/providers/validation.ts into 24 focused modules: - core.ts, enterprise.ts, search.ts, standard.ts, utils.ts - specialty/ (chat-specialty, clarifai, direct-chat, embedding-rerank, etc.) - web/ (adapta, blackbox, chatgpt, deepseek, gemini, grok, meta-ai, perplexity) - index.ts (barrel) Sub-split oversized modules: specialty.ts and web.ts into sub-directories. Original file replaced with thin re-export.
Replaces #3797 as an independent, non-stacked PR branched from release/v3.8.27.
Extracts 4.2K-line validation.ts into modular structure.
Supersedes: #3797