Skip to content

Conversation

mxsgx
Copy link

@mxsgx mxsgx commented Sep 30, 2025

See #1282

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when merging schemas by safely combining “required” fields, preventing errors or missing validations when one schema lacks a required list.
    • Enhances stability of validation behavior without altering existing interfaces or workflows.

Copy link

coderabbitai bot commented Sep 30, 2025

Walkthrough

Adjusted mergeObjectSchemas in src/schema.ts to safely combine required arrays using a nullish coalescing fallback, preventing undefined from being spread. No exported/public signatures changed.

Changes

Cohort / File(s) Summary
Schema merge guard
src/schema.ts
Safely merges required arrays in mergeObjectSchemas by using nullish coalescing (e.g., required ?? []) to avoid spreading undefined; control flow unchanged; no API surface changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at arrays that hide,
Required keys now hop side by side.
No undefined to trip our feet—
We merge with grace, tidy and neat.
Thump-thump! The schema’s path is clear,
A safer warren engineered.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the key bug being addressed—merging with an optional schema fails—without extraneous detail or ambiguity and directly reflects the change to safely handle undefined required fields.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 668c7a1 and f4828b9.

📒 Files selected for processing (1)
  • src/schema.ts (1 hunks)
🔇 Additional comments (1)
src/schema.ts (1)

1457-1457: LGTM! Safe fix for undefined required property.

The nullish coalescing operator ?? [] on schema.required prevents spreading undefined into the array when merging schemas that lack a required property (e.g., schemas with only optional fields). This is consistent with the existing pattern for newSchema?.required ?? [] and correctly addresses the issue when merging with t.Optional schemas.


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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

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.

1 participant