Skip to content

Sanitize page.get GraphQL variables for JSON-safe SSR responses#36208

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-undefined-in-graphql-variables
Draft

Sanitize page.get GraphQL variables for JSON-safe SSR responses#36208
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-undefined-in-graphql-variables

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

name: Pull Request
about: Give us some information about your proposed PR
title: ''
assignees: ''

Proposed Changes

page.get() was returning undefined optional GraphQL variables in the response metadata, which breaks strict JSON serialization in Next.js Pages Router SSR/SSG. This update keeps the outbound GraphQL request unchanged while making returned graphql.variables safe to serialize.

  • Return-path sanitization
    • omit undefined keys from graphql.variables before attaching them to successful page.get() responses and DotErrorPage.graphql
  • Request behavior preserved
    • keep existing request construction and default core variables (url, mode, languageId, fireRules, siteId) intact
    • continue passing through provided optional variables (personaId, publishDate, variantName) when explicitly set
  • Regression coverage
    • update existing page client expectations to reflect omitted undefined optionals
    • add coverage that returned graphql.variables contains no undefined values and survives JSON round-trip

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

Returned metadata now behaves like:

const result = await dotCMSClient.page.get('/');

result.graphql.variables;
// before: { url: '/', mode: 'LIVE', languageId: '1', fireRules: false, siteId: '...', personaId: undefined, publishDate: undefined, variantName: undefined }
// after:  { url: '/', mode: 'LIVE', languageId: '1', fireRules: false, siteId: '...' }

No request-side behavior is intentionally changed; the fix is limited to the response/error GraphQL metadata exposed to consumers.

Screenshots

Original Updated
N/A N/A

Copilot AI changed the title [WIP] Fix undefined serialization in graphql.variables for Next.js Sanitize page.get GraphQL variables for JSON-safe SSR responses Jun 17, 2026
Copilot AI requested a review from fmontes June 17, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants