Repository navigation
fix(what-changed): report a new property on a closed response-only schema as breaking - #744
frederikprijck wants to merge 2 commits into
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…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>
|
@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:
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. |
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: falserejects 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:
requiredIn case 04 the single breaking change is now the added property, not the
requiredentry. 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 onmain.additionalPropertiesorunevaluatedPropertiesset tofalseor 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.propertiesrule. So dodependentSchemasandpatternProperties.additionalPropertiesis treated as closed, as the existingrequiredrule already does. A new property whose schema is compatible with that dictionary value is therefore reported too.propertiesadded rule that is already breaking is left as is.Tests:
TestClosedResponseNewPropertycovers the three cases plusunevaluatedProperties, a dictionary value, an open schema and an unspecifiedadditionalProperties.TestClosedNewPropertyNeedsExclusiveResponseUsecovers request-only, shared, unused, callback and mixed-use documents, andTestClosedResponseNewPropertyHonoursConfiguredRulescovers the rules configuration.TestRequiredClosedResponseis updated because its renamed-property case now reports the breaking change on the added property.go test ./...passes andwhat-changed/modelstays at 100% statement coverage.🤖 Generated with Claude Code