Skip to content

fix(ensapi): downgrade graphql input validation errors to debug#2137

Merged
shrugs merged 5 commits into
mainfrom
fix/loud-validation-errors
May 19, 2026
Merged

fix(ensapi): downgrade graphql input validation errors to debug#2137
shrugs merged 5 commits into
mainfrom
fix/loud-validation-errors

Conversation

@shrugs
Copy link
Copy Markdown
Member

@shrugs shrugs commented May 18, 2026

Summary

  • wrap the pino logger passed to graphql-yoga so ZodErrors (raised by @pothos/plugin-zod for invalid graphql inputs) log at debug instead of error.

Why

  • yoga logs every execution error at error level, including 4xx-class client input validation failures. these are not server faults and flood integration-test (and prod) logs with full stack traces for every malformed request.

Testing

  • pnpm -F ensapi typecheck, pnpm lint, pnpm test --project ensapi — all pass.
  • a prior integration run on a separate branch surfaced the verbose zod errors at error level from this exact code path; the wrapper silences those while leaving real server errors at error.

Notes for Reviewer

  • isZodError matches both a raw ZodError and a GraphQLError whose originalError is a ZodError — both shapes appear depending on whether yoga's maskedErrors re-wraps before logging.
  • if a resolver ever throws a ZodError for a server-side reason (not input validation), it would also be downgraded. acceptable today since ZodErrors in this codebase only originate from input-validation boundaries.
  • no changeset — internal logging change, not externally observable.

Checklist

  • This PR does not change runtime behavior or semantics
  • This PR is low-risk and safe to review quickly

Wrap the pino logger passed to graphql-yoga so ZodErrors (raised by
@pothos/plugin-zod for invalid graphql inputs) log at debug instead
of error. These are 4xx-class client errors, not server faults, and
were flooding logs with stack traces for every malformed request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shrugs shrugs requested a review from a team as a code owner May 18, 2026 19:33
Copilot AI review requested due to automatic review settings May 18, 2026 19:33
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
enskit-react-example.ensnode.io Ready Ready Preview, Comment May 19, 2026 9:39pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
admin.ensnode.io Skipped Skipped May 19, 2026 9:39pm
ensnode.io Skipped Skipped May 19, 2026 9:39pm
ensrainbow.io Skipped Skipped May 19, 2026 9:39pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

Warning

Rate limit exceeded

@shrugs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 12 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16495753-cc88-4306-bf08-933778b0af50

📥 Commits

Reviewing files that changed from the base of the PR and between b353350 and adc60e0.

📒 Files selected for processing (1)
  • apps/ensapi/src/omnigraph-api/yoga.ts
📝 Walkthrough

Walkthrough

The PR customizes GraphQL error logging in Yoga to downgrade Zod validation failures to debug level instead of errors. A custom logger detects Zod errors both directly and when wrapped inside GraphQLError, logging validation failures at debug level while preserving error-level logging for other exceptions.

Changes

Zod Validation Error Logging

Layer / File(s) Summary
Zod error detection and yogaLogger implementation
apps/ensapi/src/omnigraph-api/yoga.ts
An isZodError helper identifies Zod validation errors whether they arrive directly or wrapped inside a GraphQLError. A custom yogaLogger intercepts Yoga execution errors, logs Zod validation failures at debug level with structured context, and passes through other errors at error level. The Yoga logging option is wired to use this custom logger instead of the base logger.

Poem

🐰 Quieter logs hop through the GraphQL night,
Zod errors now whisper in debug's soft light,
No more error screams for validation's small slip,
Just gentle debug logs on the information ship!

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and precisely describes the main change: downgrading GraphQL input validation errors to debug level in the ensapi package.
Description check ✅ Passed The description follows the template structure with all required sections completed: Summary, Why, Testing, Notes for Reviewer, and Pre-Review Checklist with clear, specific information.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/loud-validation-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Wraps the pino logger passed to graphql-yoga so that input-validation errors from @pothos/plugin-zod (raw ZodError or a GraphQLError whose originalError is a ZodError) log at debug instead of error, preventing client 4xx-class validation failures from flooding server logs with stack traces. Real server errors continue to log at error.

Changes:

  • Add isZodError predicate covering both raw ZodError and GraphQLError-wrapped variants.
  • Introduce a yogaLogger adapter that delegates debug/info/warn to pino and downgrades Zod-shaped errors to debug in error.
  • Wire the adapter into createYoga's logging option in place of the raw logger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 18, 2026

Greptile Summary

This PR wraps the pino logger passed to graphql-yoga with a thin adapter (yogaLogger) that intercepts logger.error calls and downgrades any ZodError (or GraphQLError-wrapped ZodError) from error to debug level, so client input-validation failures no longer flood production and integration-test logs with full stack traces.

  • Adds isZodError helper that recognises both a raw ZodError and the GraphQLError-wrapped form that yoga's masked-errors layer may produce before logging.
  • Implements yogaLogger by binding pino's debug/info/warn unchanged and replacing only error with a routing function that emits at debug for validation errors and retains error for all other execution faults.
  • Replaces logging: logger with logging: yogaLogger in the createYoga call — the only runtime change.

Confidence Score: 5/5

Safe to merge — a narrowly scoped logging wrapper with no changes to request handling, schema, or response semantics.

The change touches only how yoga's execution errors are routed to pino. The isZodError predicate correctly covers both the raw and yoga-wrapped forms of a ZodError. The non-ZodError path still logs at error level with structured context. The author confirmed the wrapper behaves as intended through integration tests, and the logic is easy to audit in a single file.

No files require special attention.

Important Files Changed

Filename Overview
apps/ensapi/src/omnigraph-api/yoga.ts Adds a yogaLogger wrapper that demotes ZodError-related execution errors from error to debug level; all other methods delegate unchanged to the pino logger. Logic is sound and well-scoped.

Sequence Diagram

sequenceDiagram
    participant Yoga as graphql-yoga
    participant YL as yogaLogger.error
    participant IZE as isZodError()
    participant Pino as pino logger

    Yoga->>YL: error(err, ...rest)
    YL->>IZE: isZodError(err)
    alt err is ZodError or GraphQLError(ZodError)
        IZE-->>YL: true
        YL->>Pino: "debug({ err }, "GraphQL input validation rejected")"
    else other execution error
        IZE-->>YL: false
        YL->>Pino: "error({ err }, "GraphQL execution error")"
    end
Loading

Reviews (6): Last reviewed commit: "fix: bot notes (loop 2)" | Re-trigger Greptile

Comment thread apps/ensapi/src/omnigraph-api/yoga.ts
Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/ensapi/src/omnigraph-api/yoga.ts`:
- Around line 19-21: Update the existing comment block that begins "Yoga logs
every execution error..." to explicitly document the tradeoff: note the current
assumption that ZodErrors originate only from `@pothos/plugin-zod` input
validation and are therefore safe to downgrade to debug, and state that any
ZodErrors thrown inside resolvers (e.g., future uses of Zod.validate or manual
throws) would also be downgraded to debug and might hide server-side faults;
mention that maintainers should revisit this behavior if resolver-side Zod usage
is added.
- Around line 22-33: The yogaLogger implementation currently uses logger.bind
and a single-arg error signature which drops extra arguments from GraphQL Yoga;
change yogaLogger so each method accepts variadic args (e.g., debug: (...args:
any[]) => logger.debug(...args), info/warn similarly) and make error: (...args:
unknown[]) => { if (args.length>0 && isZodError(args[0])) { logger.debug({ err:
args[0] }, "GraphQL input validation rejected"); return; }
logger.error(...args); } to forward all arguments and only inspect the first for
isZodError.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16903545-0443-464f-979b-f691fbb624ce

📥 Commits

Reviewing files that changed from the base of the PR and between db097c5 and b353350.

📒 Files selected for processing (1)
  • apps/ensapi/src/omnigraph-api/yoga.ts

Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
Comment thread apps/ensapi/src/omnigraph-api/yoga.ts
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

⚠️ No Changeset found

Latest commit: adc60e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io May 18, 2026 19:39 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io May 18, 2026 19:40 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io May 18, 2026 19:40 Inactive
Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
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

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

Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
Comment thread apps/ensapi/src/omnigraph-api/yoga.ts Outdated
Address review feedback from Greptile, CodeRabbit, and Vercel:
- accept variadic args in yogaLogger.error so additional yoga args aren't
  dropped at the TS signature level (.bind for the others already forwards
  at runtime)
- use structured logging form ({ err }, "GraphQL execution error") for the
  non-ZodError path to match the ZodError path

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io May 19, 2026 21:34 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io May 19, 2026 21:34 Inactive
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io May 19, 2026 21:34 Inactive
@shrugs
Copy link
Copy Markdown
Member Author

shrugs commented May 19, 2026

@greptile review

Fix comment typo flagged by copilot review bot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 19, 2026 21:39
@vercel vercel Bot temporarily deployed to Preview – ensnode.io May 19, 2026 21:39 Inactive
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io May 19, 2026 21:39 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io May 19, 2026 21:39 Inactive
@shrugs
Copy link
Copy Markdown
Member Author

shrugs commented May 19, 2026

@greptile review

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

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

@shrugs shrugs merged commit 7ab6c94 into main May 19, 2026
21 checks passed
@shrugs shrugs deleted the fix/loud-validation-errors branch May 19, 2026 21:40
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.

2 participants