fix: handle KV 414 error when IMS auth fragment leaks into org path#270
Merged
fix: handle KV 414 error when IMS auth fragment leaks into org path#270
Conversation
IMS OAuth redirect fragments (#access_token=..., #ld_hash=...) were leaking into the admin API URL path on the client side, producing an org segment up to 1986 bytes — far exceeding Cloudflare KV's 512-byte key limit. The KV GET in getAclCtx() threw a 414 error that propagated to a 500 response. Guard the DA_CONFIG.get() call with try/catch and return an empty action set on any KV error, so the request receives a clean 403 instead of a 500. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Apr 30, 2026
bosschaert
approved these changes
Apr 30, 2026
adobe-bot
pushed a commit
that referenced
this pull request
Apr 30, 2026
Collaborator
|
🎉 This PR is included in version 1.7.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
IMS OAuth redirect fragments leak into the admin API URL path on the client side. After a login redirect, the URL fragment (
#access_token=...or#ld_hash=...) is incorrectly included when constructing the config endpoint URL, resulting in requests like:getAclCtx()passes the extracted org segment directly toenv.DA_CONFIG.get()as a KV key. When that segment contains the full IMS token payload (~1986 bytes), Cloudflare KV rejects it:This unhandled exception propagated through
getDaCtx()and was caught by the generic error handler inindex.js, returning a 500 to the client.Observed in production logs over the last 12h: multiple 500 responses tied to
RayID: 9f43e69cbfa5561fand similar.Fix
Wrap the
DA_CONFIG.get(org)call ingetAclCtx()with a try/catch. On any KV error, return an emptyactionSetso the existing!authorizedcheck inindex.jsreturns a clean 403 instead of a 500.The root cause (client-side IMS fragment leaking into the URL) is a separate issue in da-website/da-collab; this fix makes the worker resilient to it.
Test plan
returns empty action set when DA_CONFIG KV GET throws 414 key-too-long error— confirms the fix handles the exact production error without throwing🤖 Generated with Claude Code