refactor(ollama): migrate auth proxy to .mts - #6974
Conversation
Convert scripts/ollama-auth-proxy.js to a typed ESM .mts entrypoint running under Node native type stripping without tsx. Preserve the fail-closed Bearer-token check, byte-length gate before timingSafeEqual, authorization header stripping, loopback backend, and EADDRINUSE exit. Trim the process needle to ollama-auth-proxy so upgrade and recovery still detect the old .js process next to the new .mts. Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
# Conflicts: # src/lib/actions/uninstall/run-plan.ts # src/lib/inference/local-adapter-lifecycle.ts
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Ollama authentication proxy moves from ChangesOllama proxy migration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant OllamaAuthProxy
participant OllamaBackend
Client->>OllamaAuthProxy: Send request with Bearer token
OllamaAuthProxy->>OllamaAuthProxy: Validate token
OllamaAuthProxy->>OllamaBackend: Forward authorized request without auth headers
OllamaBackend-->>OllamaAuthProxy: Return response
OllamaAuthProxy-->>Client: Return backend response
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage remains at 96%, unchanged from the TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most impacted files.
Updated |
PR Review Advisor — InformationalAdvisor assessment: Informational / high confidence Model lanes
Nemotron output stays in workflow artifacts and does not change the assessment above. E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/ollama-auth-proxy.mts`:
- Around line 62-81: Update the proxy request handling around proxyRes and
proxyReq to listen for proxyRes stream errors, destroy the upstream request when
clientReq disconnects, and only write the 502 fallback when
clientRes.headersSent is false. Add coverage for a backend disconnect after
partial headers or body while preserving normal piping behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 37670d50-8341-4eb1-b9ec-3ff11df57278
📒 Files selected for processing (15)
scripts/ollama-auth-proxy.jsscripts/ollama-auth-proxy.mtssrc/lib/actions/uninstall/run-plan.test.tssrc/lib/actions/uninstall/run-plan.tssrc/lib/inference/bedrock-runtime-adapter.tssrc/lib/inference/local-adapter-lifecycle.test.tssrc/lib/inference/local-adapter-lifecycle.tssrc/lib/inference/ollama/process.tssrc/lib/inference/ollama/proxy.tssrc/lib/inference/openrouter-runtime-adapter-lifecycle.tstest/e2e/live/gpu-e2e-helpers.tstest/e2e/live/ollama-auth-proxy.test.tstest/ollama-auth-proxy-handler-helpers.tstest/ollama-auth-proxy-handler.test.tstest/ollama-proxy-recovery.test.ts
💤 Files with no reviewable changes (1)
- scripts/ollama-auth-proxy.js
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
@cv @ericksoa @brandonpelfrey Maintainer E2E dispatch is ready for the exact reviewed revision below. Ordinary CI is green, CodeRabbit is clean, the canonical advisor has 0 blockers / 0 warnings / 0 suggestions, and the exact SHA passed a fresh CLI build, typecheck, 74 focused tests, and a direct plain-Node v22.19.0 proxy runtime probe. Please run E2E / PR Gate Controller from
Selected jobs: |
Summary
Migrate the host-side Ollama authentication proxy from CommonJS
scripts/ollama-auth-proxy.jsto the typed ESMscripts/ollama-auth-proxy.mtsentrypoint while preserving the existing request-handling and lifecycle contract. This maintainer salvage preserves the verified commits from #6949 and reconciles its process matcher with the Bedrock adapter migration merged in #6938.Related Issue
Resolves #6926
Part of #6918
Supersedes #6949
Changes
.mtsand retain its fail-closed Bearer-token check, byte-length gate beforetimingSafeEqual, sensitive-header stripping, loopback backend, public listener, and nonzeroEADDRINUSEbehavior..jsand current.mtsproxy processes during lifecycle cleanup and uninstall, with positive coverage for both names and negative coverage for helper and suffix near matches.processMatchername..mtsentrypoint.Type of Change
Quality Gates
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run check:diffpassed when hooks were skipped or unavailablenpm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result:npm run docsbuilds without warnings (doc changes only)Additional validation:
npm run build:cliandnpm run typecheck:clipassed. All original #6949 commits remain in the branch unchanged, and the signed merge commit records the mechanical two-file resolution against currentmain.Signed-off-by: Tinson Lai tinsonl@nvidia.com
Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit