Repository navigation
fix: ignore a malformed ?__draft= or draft cookie (the request gets the release) - #692
Merged
Merged
Conversation
cms.draftPointer returned a malformed ?__draft= value (or cookie) as is,
and cms.forDraft answers LOADER_FAILED for it, so a stray ?__draft=junk
link answered 500 on any preview host unless the site added its own
parseDraftPointer guard. draftPointer now treats a value that doesn't
parse as absent: the parameter falls back to the cookie (like an empty
one), a bad cookie is null, and the request gets the release.
forDraft itself is unchanged: an explicit forDraft("garbage") is still
LOADER_FAILED, as the api reference documents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
|
🎉 This PR is included in version 8.2.3 🎉 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.
What
cms.draftPointer(request)now returnsnullfor a?__draft=value or__deco_draftcookie thatparseDraftPointerrejects, the same as when neither is present. The documented wiring (pointer ? cms.forDraft(pointer) : cms.forRelease()) then serves the release for a stray?__draft=junklink instead of answering 500.?__draft=is ignored the way an empty one is: a valid draft cookie still applies.null. Before this change only?__draft=offwas filtered out.cms.forDraft("garbage")is unchanged and still returnsLOADER_FAILED, as the API reference and the conformance suite document. Only the request-reading path changes.Sites that carry their own
parseDraftPointerguard can drop it once they're on a release with this fix. That's a follow-up, and no site is touched here.Rendered output
A request with a malformed draft value used to get an error. It now renders the release. A valid pointer renders exactly as before.
Tests
packages/blocks/src/v8/draft.test.ts: malformed params and cookies givenull, a malformed param falls back to a valid cookie, and the end-to-end wiring serves the release revision.bun run test(packages/blocks): all draft, settings, cms and sdk-conformance tests pass. The only failures are unrelated to this change:delivery.cli.test.tsDS-2 also fails on main after fix(protocol): discard also unstages the discarded blocks #689 (git.tsnow runsupdate-index), andschema.test.tshit 5s timeouts on a loaded machine. Different files time out on different runs.bun run typecheck(packages/blocks),bun run lint,bun run skills:check.🤖 Generated with Claude Code
https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
Summary by cubic
cms.draftPointernow treats a?__draft=value or__deco_draftcookie that doesn't parse as absent, so a malformed pointer renders the release instead of aLOADER_FAILEDerror. Previously only?__draft=offwas filtered out.null.cms.forDraft("garbage")is unchanged and still fails; only the request-reading path changes.Written for commit 6b78b1e. Summary will update on new commits.