Skip to content

chore(FR-2814): patch relay-runtime to expose full @catch error details#7247

Open
yomybaby wants to merge 1 commit into
mainfrom
chore/FR-2814-patch-relay-runtime-catch-error-details
Open

chore(FR-2814): patch relay-runtime to expose full @catch error details#7247
yomybaby wants to merge 1 commit into
mainfrom
chore/FR-2814-patch-relay-runtime-catch-error-details

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented May 6, 2026

Resolves #7246(FR-2814)

Summary

  • Patch relay-runtime@20.1.1 so the errors array exposed by @catch fields preserves the full GraphQL error object (message, extensions, etc.) instead of the upstream-stripped subset (path + severity only).
  • Patch is registered in pnpm-workspace.yaml under patchedDependencies so it applies automatically for all developers and CI; the patch file lives in react/patches/ next to the existing patches.
  • Surface area is intentionally minimal: a single case 'relay_field_payload.error': in RelayReader._asResult is changed to return error.error directly, with an inline comment explaining the deviation from upstream.

Why

Relay 18+ deliberately strips message from the per-field error objects (and never exposes extensions) for PII safety. In our codebase this forces awkward workarounds — e.g. PrometheusQueryTemplatePreview parses the GraphQL error wrapper string via indexOf to recover backend messages. The official escape hatches (relayFieldLogger global side-channel, schema-level error payloads) are either too coarse for component-level UX or require backend changes per call site. We accept the PII trade-off in exchange for a usable error UX in our internal admin tooling.

Test plan

  • pnpm install re-applies the patch cleanly (verify a _patch_hash= directory under node_modules/.pnpm/relay-runtime@20.1.1...).
  • In a query that uses @catch, when the backend returns a field error, the resulting errors[i] includes message (and extensions when present), in addition to path.
  • bash scripts/verify.sh=== ALL PASS ===.

Notes

  • TypeScript types in generated artifacts use Result<T, unknown> for the error type, so consumers need to cast at the use site (e.g. errors[0] as { path: readonly (string|number)[]; message?: string; extensions?: Record<string, unknown> }). No type changes are required in this PR.
  • Follow-up: replace the indexOf-based message parsing in PrometheusQueryTemplatePreview with direct errors[0].message access (separate PR / Jira issue).

Upstream Relay strips `message` (and never exposes `extensions`) from
the per-field error objects surfaced via `@catch`, citing PII safety.
This patches `RelayReader._asResult` to return the full GraphQL error
object for `relay_field_payload.error` so components can read
`message` / `extensions` directly instead of parsing wrapper text or
routing through the global `relayFieldLogger` side-channel.
Copy link
Copy Markdown
Member Author

yomybaby commented May 6, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the size:S 10~30 LoC label May 6, 2026
@yomybaby yomybaby marked this pull request as ready for review May 6, 2026 03:54
Copilot AI review requested due to automatic review settings May 6, 2026 03:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a pnpm patch for relay-runtime@20.1.1 to stop Relay’s @catch per-field error handling from stripping GraphQL error details, so WebUI components can access the full error object (e.g., message, extensions) directly from the errors array.

Changes:

  • Add a pnpm patch that changes RelayReader’s handling of relay_field_payload.error to return the full error.error object.
  • Register the patch via patchedDependencies so it is applied consistently in developer installs and CI.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
react/patches/relay-runtime@20.1.1.patch Modifies Relay runtime’s field error mapping to expose the complete GraphQL error object instead of a sanitized subset.
pnpm-workspace.yaml Registers the new relay-runtime patch under patchedDependencies so pnpm applies it automatically.

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

Labels

size:S 10~30 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch relay-runtime to expose full GraphQL error details on @catch fields

2 participants