Skip to content

Fix Schema JSON stringification of undefined - #6633

Merged
gcanti merged 2 commits into
mainfrom
fix/schema-stringify-json-undefined
Jul 25, 2026
Merged

Fix Schema JSON stringification of undefined#6633
gcanti merged 2 commits into
mainfrom
fix/schema-stringify-json-undefined

Conversation

@gcanti

@gcanti gcanti commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • JSON stringification now consistently reports invalid values when serialization fails or produces no output, including unsupported root values and cases where the root value is removed.
  • Tests

    • Added coverage to verify that serialization failures (including undefined output) correctly produce an InvalidValue result.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 25, 2026
@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: abddba3

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

@effect-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fa1d07b-6da5-4e7e-9b0a-00a7ba515b47

📥 Commits

Reviewing files that changed from the base of the PR and between f0d29b2 and abddba3.

📒 Files selected for processing (1)
  • packages/effect/test/schema/SchemaGetter.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/effect/test/schema/SchemaGetter.test.ts

📝 Walkthrough

Walkthrough

SchemaGetter.stringifyJson now treats undefined results from JSON.stringify as SchemaIssue.InvalidValue failures. Tests use @effect/vitest and verify the new failure behavior.

Changes

SchemaGetter JSON stringification

Layer / File(s) Summary
Validate stringifyJson output
packages/effect/src/SchemaGetter.ts, packages/effect/test/schema/SchemaGetter.test.ts
stringifyJson throws when JSON.stringify returns undefined, routing the result through existing invalid-value handling; tests verify the failure and use @effect/vitest imports.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
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.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@packages/effect/test/schema/SchemaGetter.test.ts`:
- Around line 18-23: Update the stringifyJson failure test around
SchemaGetter.stringifyJson to inspect the error returned by Effect.flip,
asserting that its _tag is SchemaIssue.InvalidValue and, if available in the
existing issue shape, that actual reflects the undefined value. Preserve the
test’s current input and effect execution while replacing the void-only
assertion with the contract-specific validation.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9614a8f0-6d3b-412b-bbba-393b1937f635

📥 Commits

Reviewing files that changed from the base of the PR and between c8d73fd and f0d29b2.

📒 Files selected for processing (2)
  • packages/effect/src/SchemaGetter.ts
  • packages/effect/test/schema/SchemaGetter.test.ts

Comment thread packages/effect/test/schema/SchemaGetter.test.ts
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.64 KB 6.64 KB 0.00 KB (0.00%)
batching.ts 9.42 KB 9.42 KB 0.00 KB (0.00%)
brand.ts 6.25 KB 6.25 KB 0.00 KB (0.00%)
cache.ts 10.13 KB 10.13 KB 0.00 KB (0.00%)
config.ts 19.08 KB 19.08 KB 0.00 KB (0.00%)
differ.ts 18.38 KB 18.38 KB 0.00 KB (0.00%)
http-client.ts 20.73 KB 20.73 KB 0.00 KB (0.00%)
logger.ts 10.30 KB 10.30 KB 0.00 KB (0.00%)
metric.ts 8.56 KB 8.56 KB 0.00 KB (0.00%)
optic.ts 7.41 KB 7.41 KB 0.00 KB (0.00%)
pubsub.ts 14.17 KB 14.17 KB 0.00 KB (0.00%)
queue.ts 11.10 KB 11.10 KB 0.00 KB (0.00%)
schedule.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
schema-class.ts 18.16 KB 18.16 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 27.86 KB 27.86 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.14 KB 24.14 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.68 KB 12.68 KB 0.00 KB (0.00%)
schema-string.ts 10.36 KB 10.36 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.38 KB 14.38 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.93 KB 20.93 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 23.34 KB 23.34 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.27 KB 18.27 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.01 KB 18.01 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.86 KB 17.86 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 21.47 KB 21.47 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.55 KB 18.55 KB 0.00 KB (0.00%)
schema.ts 17.43 KB 17.43 KB 0.00 KB (0.00%)
stm.ts 12.07 KB 12.07 KB 0.00 KB (0.00%)
stream.ts 9.36 KB 9.36 KB 0.00 KB (0.00%)

@gcanti
gcanti merged commit 30effdb into main Jul 25, 2026
15 checks passed
@gcanti
gcanti deleted the fix/schema-stringify-json-undefined branch July 25, 2026 20:53
@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in PR Backlog Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant