Skip to content

fix!: throw when querying drafts perspective with the API-CDN - #1304

Draft
jordanl17 wants to merge 5 commits into
mainfrom
cursor/cdn-drafts-perspective-error-5863
Draft

jordanl17 wants to merge 5 commits into
mainfrom
cursor/cdn-drafts-perspective-error-5863

Conversation

@jordanl17

@jordanl17 jordanl17 commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Note

Hold this for the next major release of @sanity/client. It is a valid SemVer break and should land with that major, not as a dedicated v9 for this change alone.

Fixes SAPP-2685.

Reproduction

The JS client still only warned when perspective: 'drafts' (or 'previewDrafts') was combined with useCdn: true. Gradient rejects that combination on the API-CDN; the client used to swallow it, switch to the Live API, and print:

The Sanity client is configured with the perspective set to drafts or previewDrafts, which doesn't support the API-CDN. The Live API will be used instead.

That matches the original report. We own this path in @sanity/client.

Before / after

Covered in test/client/cdnPerspective.test.ts.

Before: createClient({useCdn: true, perspective: 'drafts'}).fetch(...) warned and queried api.sanity.io.
After: the same call throws:

The Sanity client is configured with the perspective set to drafts or previewDrafts, which does not support the API-CDN. Set useCdn: false.

Still allowed:

  • useCdn: false + drafts (Live API)
  • useCdn: true + published / raw (CDN)
  • per-fetch {useCdn: false} on a drafts client
  • stacked perspectives that do not include drafts still fall back to the Live API with a warning (same as today, so release stacks keep working)

This remains a major (fix!) because existing queries that succeeded with a warning will now throw. The old warning asked callers to hide it; it was not a documented deprecation with a removal window.

Open in Web Open in Cursor 

Co-authored-by: Jordan Lawrence <jordanl17@users.noreply.github.com>
@vercel

vercel Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
tsdocs-client Ignored Ignored Sep 7, 2026 3:02pm UTC

Request Review

@jordanl17
jordanl17 marked this pull request as ready for review August 27, 2026 16:37
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 83.75% 1923 / 2296
🔵 Statements 83.62% 1997 / 2388
🔵 Functions 78.43% 520 / 663
🔵 Branches 82.98% 1405 / 1693
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/config.ts 92.5% 92% 100% 92.4% 27, 99-100, 126, 129, 136-138
src/types.ts 100% 100% 100% 100%
src/warnings.ts 100% 100% 100% 100%
src/data/dataMethods.ts 85.96% 92.18% 71.84% 86.08% 145-146, 287, 350-351, 445-478, 514-575, 664, 705-706, 1249-1273, 1279, 1287, 1305
Generated in workflow #5056 for commit aa22946 by the Vitest Coverage Report Action

@rexxars

rexxars commented Aug 27, 2026

Copy link
Copy Markdown
Member

@jordanl17 Is there a sense of urgency behind this? We just recently released a new major, and getting all surfaces and peer dependency ranges aligned has already taken quite a bit of time. Obviously that's a situation we'd like to improve/make easier, but just questioning whether or not this is really the right time to do another major. I personally do not have the time to cascade this throughout repos. If there's no immediate urgency, I'd like to schedule this under the v9 milestone

@rexxars rexxars left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejecting this based on my previous comment to avoid it getting merged without taking it into account - happy to re-review if urgent.

@rexxars rexxars added this to the v9 milestone Aug 28, 2026
Comment thread .changeset/pr-1304.md
@@ -0,0 +1,6 @@
<!-- auto-generated -->
---
'@sanity/client': major

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol clanker, we are not doing a major for this

cursoragent and others added 2 commits September 7, 2026 15:01
Co-authored-by: Jordan Lawrence <jordanl17@users.noreply.github.com>
@cursor cursor Bot changed the title feat!: throw when querying drafts perspective with the API-CDN fix!: throw when querying drafts perspective with the API-CDN Sep 7, 2026
@cursor
cursor Bot marked this pull request as draft September 7, 2026 15:01
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

📚 TypeDoc Generation Result

✅ TypeDoc generated successfully!

  • File size: 4.0M
  • Total exports: 253
  • Artifact: typedoc-2c71d0c40c9be74d13b5d9c45880958726ba92a1
  • HTML docs preview: Download artifact

The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants