Skip to content

Conversation

@domdomegg
Copy link
Contributor

Summary

Implements detection of JSON Schema enum changes with context-aware breaking change detection.

Resolves the issue where enum arrays being extended or reduced were not detected by the tool.

Changes

  • Added EnumAdd and EnumRemove change types with context flags (lhs_has_no_enum and rhs_has_no_enum)
  • Smart breaking change logic:
    • Adding values to existing enum: non-breaking (accepts more data)
    • Removing values from existing enum: breaking (rejects previously valid data)
    • Adding enum constraint entirely: breaking (restricts previously valid data)
    • Removing enum constraint entirely: non-breaking (accepts more data)
  • Comprehensive test coverage: 9 test cases covering all scenarios including the real-world case from the issue

Examples

# Adding a value to existing enum (non-breaking)
$ json-schema-diff old.json new.json
{"path":"","change":{"EnumAdd":{"added":"debug","lhs_has_no_enum":false}},"is_breaking":false}

# Removing a value from existing enum (breaking)
$ json-schema-diff old.json new.json  
{"path":"","change":{"EnumRemove":{"removed":"debug","rhs_has_no_enum":false}},"is_breaking":true}

# Adding enum constraint (breaking)
$ json-schema-diff old.json new.json
{"path":"","change":{"EnumAdd":{"added":"error","lhs_has_no_enum":true}},"is_breaking":true}

# Removing enum constraint (non-breaking)
$ json-schema-diff old.json new.json
{"path":"","change":{"EnumRemove":{"removed":"error","rhs_has_no_enum":true}},"is_breaking":false}

Fixes #38

Implements detection of JSON Schema enum changes, resolving issue getsentry#38.

Changes:
- Add EnumAdd and EnumRemove change types with context flags
- Track whether enum constraint is being added/removed entirely
- Smart breaking change logic:
  - Adding values to existing enum: non-breaking (accepts more)
  - Removing values from existing enum: breaking (rejects data)
  - Adding enum constraint: breaking (restricts values)
  - Removing enum constraint: non-breaking (relaxes values)
- Comprehensive test coverage with 9 test cases including the real-world
  scenario from the original issue

Fixes getsentry#38

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@domdomegg domdomegg requested a review from a team as a code owner October 7, 2025 13:43
@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (release) Replace release bot with GH app by Jeffreyhung in #41
  • Add enum support with context-aware breaking change detection by domdomegg in #46
  • Add string validation support (pattern, minLength, maxLength) by domdomegg in #51
  • Support format by brhutchins in #45
  • Support custom ids and $defs from draft 2020-12 by cakemanny in #44

Internal Changes 🔧

Release

  • Fix changelog-preview permissions by BYK in #54
  • Switch from action-prepare-release to Craft by BYK in #52

Other

  • Use pull_request_target for changelog preview by BYK in #53

Other

  • Fix clippy lints by untitaker in #42

🤖 This preview updates automatically when you update the PR.

@untitaker untitaker merged commit a81ac3b into getsentry:main Jan 29, 2026
5 checks passed
@untitaker
Copy link
Member

thanks and sorry for the delay! this slipped through the cracks

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.

Enum support

2 participants