Skip to content

fix(what-changed): report a new property on a closed response-only schema as breaking - #744

Open
frederikprijck wants to merge 2 commits into
pb33f:mainfrom
frederikprijck:fix/what-changed-closed-response-new-property
Open

frederikprijck wants to merge 2 commits into
pb33f:mainfrom
frederikprijck:fix/what-changed-closed-response-new-property

Conversation

@frederikprijck

Copy link
Copy Markdown

Closes #730.

As agreed in the issue (option 2), a new property on a closed, response-only schema is now reported as breaking whether or not it is required. An old client that validates strictly against additionalProperties: false rejects every response that carries the new property, so the server omitting it is not enough to make the addition safe.

Results for the three cases in the reproduction repository, compared before and after this change:

Case Change to the closed response schema Before After
07 new optional property 1 change, 0 breaking 1 change, 1 breaking
04 new property that is also required 2 changes, 1 breaking 2 changes, 1 breaking
08 existing property added to required 1 change, 0 breaking 1 change, 0 breaking

In case 04 the single breaking change is now the added property, not the required entry. Requiring a property that is new in the same change no longer counts a second time. The other five cases in the reproduction repository report the same numbers as on main.

  • Applies only when the old schema restricts properties (additionalProperties or unevaluatedProperties set to false or to a schema) and both document versions prove that only responses use it. The usage lookup runs only when a property is added to a schema like that.
  • Open schemas, shared schemas, request-only schemas and uncertain uses keep the configured properties rule. So do dependentSchemas and patternProperties.
  • A schema-valued additionalProperties is treated as closed, as the existing required rule already does. A new property whose schema is compatible with that dictionary value is therefore reported too.
  • A configured properties added rule that is already breaking is left as is.

Tests: TestClosedResponseNewProperty covers the three cases plus unevaluatedProperties, a dictionary value, an open schema and an unspecified additionalProperties. TestClosedNewPropertyNeedsExclusiveResponseUse covers request-only, shared, unused, callback and mixed-use documents, and TestClosedResponseNewPropertyHonoursConfiguredRules covers the rules configuration. TestRequiredClosedResponse is updated because its renamed-property case now reports the breaking change on the added property. go test ./... passes and what-changed/model stays at 100% statement coverage.

🤖 Generated with Claude Code

…hema as breaking

An old client that validates a response against a closed schema (additionalProperties
or unevaluatedProperties restricted) rejects every response that carries a property the
old schema did not declare, whether or not the new property is required. Only the
required case was reported, so adding an optional property went unnoticed.

A property added to a schema that only responses use, and whose old version restricts
properties, is now breaking. Requiring that new property no longer counts a second time.
Requiring a property the old schema already declared stays non-breaking.

Open schemas, shared schemas, request-only schemas and uncertain uses keep the configured
classification, as do dependentSchemas and patternProperties.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (141facc) to head (2643ada).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #744   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          329       329           
  Lines        42257     42286   +29     
=========================================
+ Hits         42257     42286   +29     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…breaking

A new property on a closed response-only schema is not new to an old
client when an existing patternProperties entry already admits it with
an identical schema. Only that proof clears the breaking flag.

Co-Authored-By: Claude <noreply@anthropic.com>
@frederikprijck

Copy link
Copy Markdown
Author

@daveshanley, one follow-up on the option 2 decision, which I'd like your view on before this merges.

A new property on a closed response-only schema is now always breaking. That follows the contract: an old client that validates strictly rejects the new field. It doesn't match how every consumer works, though. A team that never validates responses against the schema, or that ignores unknown fields, would get a breaking change it doesn't care about.

Right now they can't turn it off. schema.properties.added defaults to false, and IsBreaking returns a plain bool. An explicit false is therefore indistinguishable from the default, so the closed-response check still applies. Setting properties.added: true makes it breaking everywhere, but nothing makes it non-breaking.

Two options:

  1. Add a dedicated rule key, for example schema.closedResponseProperties, defaulting to added: true. propertyAdditionRule would read it instead of hard-coding true. Teams that don't validate can switch it off without touching the general properties rule. It adds a small amount of public config surface.
  2. Keep it as is and treat the missing opt-out as a known limitation, perhaps with a follow-up issue.

I lean towards option 1, but it adds public config, so it's your call. I'm happy to include it in this PR or send it as a follow-up.

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.

what-changed: is a new property on a closed response-only schema meant to be breaking only when it is required?

1 participant