Skip to content

Fix four real-world read/write bugs found validating against the Stri… - #72

Merged
noha merged 1 commit into
masterfrom
stripe-spec-validation-fixes
Jul 30, 2026
Merged

Fix four real-world read/write bugs found validating against the Stri…#72
noha merged 1 commit into
masterfrom
stripe-spec-validation-fixes

Conversation

@noha

@noha noha commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

…pe API spec

Found while driving OpenAPI-Client against the actual Stripe OpenAPI spec and stripe-mock (not just the Petstore test fixture):

  • JSONSchemaArray>>read: computed its result but never returned it (no ^), so array-typed values always silently became the schema object itself. The tuple-validation branch also iterated the schema's own #items instead of the actual data collection.
  • JSONSchemaObject>>readObject: sent #ifTrue: directly to #additionalProperties, which crashes whenever a schema sets additionalProperties to a nested schema (or leaves it unset) rather than a literal boolean - both are valid per spec. Stripe's metadata schemas do exactly this.
  • JSONSchemaAnyObject had no #read:, hit whenever a property with no fixed shape (e.g. an anyOf collapsing to "accept anything") is read back.
  • JSONSchemaString/JSONPrimitiveSchema sent #ifTrue: directly to #nullable, which is nil (not a boolean) for any schema object built by NeoJSON's reflective instantiation - i.e. every schema parsed from a document, primed or not. Changed to a proper accessor that treats unset as permissive, since OpenAPI's "nullable" keyword on a property is not currently threaded through nested schema reads at all (properties are always parsed as base JSONSchemaDefinition, which does not carry it) - a separate, larger gap left for follow-up.

…pe API spec

Found while driving OpenAPI-Client against the actual Stripe OpenAPI spec
and stripe-mock (not just the Petstore test fixture):

- JSONSchemaArray>>read: computed its result but never returned it (no ^),
  so array-typed values always silently became the schema object itself.
  The tuple-validation branch also iterated the schema's own #items
  instead of the actual data collection.
- JSONSchemaObject>>readObject: sent #ifTrue: directly to
  #additionalProperties, which crashes whenever a schema sets
  additionalProperties to a nested schema (or leaves it unset) rather than
  a literal boolean - both are valid per spec. Stripe's metadata schemas
  do exactly this.
- JSONSchemaAnyObject had no #read:, hit whenever a property with no fixed
  shape (e.g. an anyOf collapsing to "accept anything") is read back.
- JSONSchemaString/JSONPrimitiveSchema sent #ifTrue: directly to
  #nullable, which is nil (not a boolean) for any schema object built by
  NeoJSON's reflective instantiation - i.e. every schema parsed from a
  document, primed or not. Changed to a proper accessor that treats unset
  as permissive, since OpenAPI's "nullable" keyword on a property is not
  currently threaded through nested schema reads at all (properties are
  always parsed as base JSONSchemaDefinition, which does not carry it) -
  a separate, larger gap left for follow-up.
@noha
noha merged commit be9a7aa into master Jul 30, 2026
3 of 4 checks passed
@noha
noha deleted the stripe-spec-validation-fixes branch July 30, 2026 10:17
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