Skip to content

fix: add default None to optional command schema fields#24

Merged
alfonsosastre merged 1 commit intomainfrom
fix/optional-command-fields
Feb 26, 2026
Merged

fix: add default None to optional command schema fields#24
alfonsosastre merged 1 commit intomainfrom
fix/optional-command-fields

Conversation

@alfonsosastre
Copy link
Contributor

Summary

  • Adds = None default to all optional (| None) fields in StartSession, ReserveNow command schemas across OCPI versions 2.1.1, 2.2.1, and 2.3.0
  • Without the default, Pydantic v2 treats X | None as "required but nullable", causing 422 validation errors when callers correctly omit optional fields per OCPI spec (cardinality ?)
  • This was triggered by Payter sending a START_SESSION without connector_id, which is valid per spec but rejected by our schema

Test plan

  • All 296 existing tests pass
  • Verify Payter can send START_SESSION without connector_id and get a valid response

Made with Cursor

Per OCPI spec, fields like evse_uid, connector_id, and
authorization_reference in StartSession and ReserveNow are optional
(cardinality ?). Without `= None` default, Pydantic v2 requires them
to be present in the request body even if null, causing 422 errors
when callers correctly omit them.

Made-with: Cursor
@alfonsosastre alfonsosastre merged commit d2d02f1 into main Feb 26, 2026
4 checks passed
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