Skip to content

fix(schema): strip null bytes from ParamReason - #1326

Merged
dcramer merged 2 commits into
mainfrom
seer/fix/strip-null-bytes-from-reason
Sep 24, 2026
Merged

dcramer merged 2 commits into
mainfrom
seer/fix/strip-null-bytes-from-reason

Conversation

@sentry

@sentry sentry Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This PR fixes an ApiValidationError that occurs when AI clients provide a reason string containing null (\0) bytes. The Sentry API rejects comments with null characters, leading to a Bad Request error.

The root cause was identified as the ParamReason Zod schema in packages/mcp-core/src/schema.ts not stripping these null bytes. The schema only trimmed whitespace and enforced a minimum length, allowing \0 characters to pass through to the Sentry API.

Changes Made:

  • Added .transform((s) => s.replace(/\0/g, "")) to the ParamReason Zod definition in packages/mcp-core/src/schema.ts. This ensures that any null bytes are removed from the reason string before it is used in API calls.
  • Added a new test case in packages/mcp-core/src/tools/catalog/update-issue.test.ts to verify that prepareToolParams (which uses the Zod schema) correctly strips null bytes from the reason parameter.

Fixes MCP-SERVER-FYA

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@github-actions github-actions Bot added the risk: low PR risk score: low label Sep 22, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Corrected and pushed 7a52384. The original transform ran after min(1), allowing a NUL-only reason to become empty, and changed generated-schema ordering without updating definitions (the failing CI step). Using Zod overwrite before trim/min preserves the input JSON schema and validates the sanitized value. Added NUL-only/whitespace regression coverage. All 31 update-issue tests, check:generated, and the full repository tsc/lint/test gate pass locally. Awaiting the new head's CI checks.

@dcramer
dcramer merged commit d50ac37 into main Sep 24, 2026
21 checks passed
@dcramer
dcramer deleted the seer/fix/strip-null-bytes-from-reason branch September 24, 2026 15:57
BYK added a commit that referenced this pull request Sep 30, 2026
Pulls in the synchronous output fd release from
[BYK/binpatch#37](BYK/binpatch#37) —
`applyReaderToFile` now closes the output fd via `fs.closeSync`
before returning, eliminating the ETXTBSY race that broke the
delta-upgrade → full-download fallback on Linux.

Verified locally:
- `pnpm --filter sentry run typecheck` — clean
- `pnpm --filter sentry run test:unit` — 8754 passed | 15 skipped

Also depends on
[BYK/binpatch#38](BYK/binpatch#38) (adds the
github target to .craft.yml — internal change, no runtime impact).
mr-danya pushed a commit to mr-danya/sentry-mcp that referenced this pull request Oct 6, 2026
Pulls in the synchronous output fd release from
[BYK/binpatch#37](BYK/binpatch#37) —
`applyReaderToFile` now closes the output fd via `fs.closeSync`
before returning, eliminating the ETXTBSY race that broke the
delta-upgrade → full-download fallback on Linux.

Verified locally:
- `pnpm --filter sentry run typecheck` — clean
- `pnpm --filter sentry run test:unit` — 8754 passed | 15 skipped

Also depends on
[BYK/binpatch#38](BYK/binpatch#38) (adds the
github target to .craft.yml — internal change, no runtime impact).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant