fix: add proper error handling for missing authorization header (#11096)#12597
Conversation
|
This PR targets the Automatically setting the base branch to |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
WalkthroughAuth dependency now treats requests as anonymous when credential details are missing and disables admin impersonation if the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Pull request overview
Refines authentication-related dependency behavior in the platform auth library and (separately) updates the frontend Docker image base.
Changes:
- Adjust
get_optional_user_idto treat missing/empty bearer credentials as anonymous access. - Treat
X-Act-As-User-Id: none(case-insensitive) as “no impersonation”. - Update
autogpt_platform/frontendDockerfile base/prod images to Node 22.22 on Alpine 3.23.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| autogpt_platform/frontend/Dockerfile | Updates Node/Alpine base images used to build and run the frontend container. |
| autogpt_platform/autogpt_libs/autogpt_libs/auth/dependencies.py | Tightens optional auth credential handling and adds an impersonation-header sentinel behavior. |
229774a to
df4dc9f
Compare
df4dc9f to
46932df
Compare
…ificant-Gravitas#12561) ## Summary Upgrade the frontend **Docker image** from **Node.js v21** (EOL since June 2024) to **Node.js v22 LTS** (supported through April 2027). > **Scope:** This only affects the **Dockerfile** used for local development (`docker compose`) and CI. It does **not** affect Vercel (which manages its own Node.js runtime) or Kubernetes (the frontend Helm chart was removed in Dec 2025 — the frontend is deployed exclusively via Vercel). ## Why - Node v21.7.3 has a **known TransformStream race condition bug** causing `TypeError: controller[kState].transformAlgorithm is not a function` — this is [BUILDER-3KF](https://significant-gravitas.sentry.io/issues/BUILDER-3KF) with **567,000+ Sentry events** - The error is entirely in Node.js internals (`node:internal/webstreams/transformstream`), zero first-party code - Node 21 is **not an LTS release** and has been EOL since June 2024 - `package.json` already declares `"engines": { "node": "22.x" }` — the Dockerfile was inconsistent - Node 22.x LTS (v22.22.1) fixes the TransformStream bug - Next.js 15.4.x requires Node 18.18+, so Node 22 is fully compatible ## Changes - `autogpt_platform/frontend/Dockerfile`: `node:21-alpine` → `node:22.22-alpine3.23` (both `base` and `prod` stages) ## Test plan - [ ] Verify frontend Docker image builds successfully via `docker compose` - [ ] Verify frontend starts and serves pages correctly in local Docker environment - [ ] Monitor Sentry for BUILDER-3KF — should drop to zero for Docker-based runs Signed-off-by: Zendy <50132805+zendy199x@users.noreply.github.com>
fa909c7 to
df397c3
Compare
Fixes #11096
Why / What / How
The current authentication dependencies likely raise an ApiError when the Authorization header is missing, but the error message may not be clear or the header extraction logic may not be robust. This change improves header extraction and provides clearer, more actionable error messages.
This PR refactors the authorization header extraction logic in
dependencies.pyto add proper error handling for missing or malformed Authorization headers, ensuring consistent and informative error responses.The change introduces explicit checks for the presence and format of the Authorization header before attempting to parse it. If the header is missing, a descriptive error is raised with a clear message indicating the expected format. The implementation avoids relying on implicit behavior or generic exceptions.
Changes 🏗️
autogpt_platform/autogpt_libs/autogpt_libs/auth/dependencies.pyto:AuthorizationheaderChecklist 📋
For code changes:
For configuration changes:
.env.defaultis updated or already compatible with my changesdocker-compose.ymlis updated or already compatible with my changes