fix(images): allow managed pool candidates to serve image generation with admission bearer auth - #5927
fix(images): allow managed pool candidates to serve image generation with admission bearer auth#5927rrmlima wants to merge 3 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughImage forwarding now retains eligible OpenAI pool candidates when the proxy admission credential cannot be forwarded. The handler resolves credentials from those candidates and validates completed headers before forwarding. Tests cover pool-account forwarding and missing pool credentials. ChangesImage pool forwarding
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Managed pool image forwarding has no identified issue that should block merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Bearer-authenticated image requests can now use managed pool accounts without forwarding the caller’s secret. An interrupted request may, however, leave a pool recovery reservation held and delay service for other callers. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
리뷰 · 우선순위 64 / 80그림 그리기 요청이 프록시 입장 비밀번호만 들고 오면, 저장해 둔 ChatGPT 계정을 쓰게 고칩니다. 바탕은
이제는 손님이 준 값을 그대로 올릴 수 있는 라인 - 라인 - 메인테이너의 판단이 필요한 지점 입장 비밀번호로 온 그림 요청은 이제 풀을 먼저 탑니다. 풀이 되면 저장 토큰으로 바꿉니다. 새 테스트가 그 성공을 확인합니다. 풀이 식었거나 로그인이 깨지면, 지금 코드는 API 키가 있어도 그 오류를 그대로 돌려줍니다. 어제는 이 손님이 풀을 타지 않아서 API 키로 그림이 나갔습니다. 696줄 주석은 풀이 식어도 API 키가 놀면 안 된다고 적습니다. 750줄은 풀 오류를 그대로 돌려줍니다. 이 손님에게 어느 쪽을 쓸지 정해 주세요. 이 PR은 아직 초안입니다. 본문의 준비 체크 네 칸이 비어 있습니다. 너의 추천 풀로 그림을 보내는 수정은 두세요. 749줄 검사는 이 댓글은 grok-bot이 작성했습니다 |
…with admission bearer auth
When a client authenticates to the OpenCodex proxy using the proxy admission
bearer ('Authorization: Bearer <token>'), the images handler previously set
'skipOpenAiForwardForAdmissionBearer = true', dropping all forward candidates.
This prevented healthy managed pool accounts (which use proxy-managed OAuth
credentials rather than forwarding caller credentials) from serving
/v1/images/generations, causing an unintended fallback to Google Antigravity
or returning a 400 error.
This patch:
1. Replaces the blind drop of all forward candidates with candidate-level
filtering: candidates in 'direct' mode (which forward caller credentials)
are skipped when the caller authenticates with proxy admission secrets,
while managed pool candidates remain eligible.
2. Adds a post-assembly validation asserting that assembled outbound headers
never contain proxy admission secrets.
3. Adds automated regressions in server-images.test.ts verifying pool account
routing with admission bearers and safe fallback behavior.
Fixes lidge-jun#4213 (partially: built-in image generation routing through proxy)
…re under admission bearer 1. Wrap post-assembly admission secret validation in try/catch to safely release probe lease on failure and return 500 internal_error instead of unhandled exceptions. 2. Replace redundant direct-fallback test with pool-auth-failure test, verifying that admission bearer requests surface pool auth failures cleanly without hiding them behind keyed provider fallback.
7c1e862 to
6ff9e63
Compare
Carry the scoped provider-owned Images fix from #5927 onto current dev. Keep Direct ineligible for a proxy admission bearer, give the selected upstream credential sole Authorization ownership, and fail before a paid send on invalid credentials. Co-authored-by: Rafael Moreira <rrmlima@gmail.com>
#6097) Allow a proxy admission bearer to use a managed Codex Pool account for standalone Images requests; Direct stays ineligible because it would forward the caller's bearer. A configured key's provider/model scope is checked against each forward destination before any stored Pool credential is resolved, refreshed or leased. The selected upstream credential owns the Images Authorization header, invalid pre-send credentials are refused without a paid request, and the recovery probe lease is released on every early return, including a client cancel during the upstream send. Carries #5927. Co-authored-by: Rafael Moreira <rrmlima@gmail.com>
|
Thank you, @rrmlima. Your fix landed on It was carried rather than merged directly because |
Summary
When clients (such as the standard OpenAI SDK, LangChain, or external agents) connect to OpenCodex using the conventional proxy admission bearer (
Authorization: Bearer <proxy-secret>),/v1/images/generationspreviously flaggedskipOpenAiForwardForAdmissionBearer = trueand discarded all OpenAI forward candidates.As a result:
~/.codex/auth.json), even though pool accounts never forward the caller's bearer (they substitute it with proxy-managed OAuth tokens).gemini-3.1-flash-image) or failed with400 invalid_request_error("Built-in image generation needs an OpenAI upstream...").x-opencodex-api-keyheader to bypass this guard.This PR fixes the routing by making candidate eligibility granular:
callerBearerMayBeForwarded === false), only candidates indirectmode (which would attempt to forward caller credentials) are skipped. Candidates in managedpoolmodes remain eligible.fetch(), wrapped in try/catch to safely release probe leases and return a sanitized 500 error on unexpected validation failure.tests/server/server-images.test.tsverifying:Fixes #4213 (partially: built-in image generation routing through proxy).
Verification
Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.