Skip to content

fix: tolerate unknown enum values on deserialization (#203, #205, #206)#231

Open
CedricConday wants to merge 1 commit into
XeroAPI:masterfrom
CedricConday:fix/tolerate-unknown-enum-values-203
Open

fix: tolerate unknown enum values on deserialization (#203, #205, #206)#231
CedricConday wants to merge 1 commit into
XeroAPI:masterfrom
CedricConday:fix/tolerate-unknown-enum-values-203

Conversation

@CedricConday

Copy link
Copy Markdown

Fixes #203, #205, #206.

The Xero API returns enum values this generated SDK predates — e.g. a contact with TaxNumberType = "TAXNUMBERTYPE/SSN" (#203, #205) or a linked transaction with SourceTransactionTypeCode = "RECEIPT" (#206). The per-attribute setters validate against a hardcoded allowed_values and raise ValueError, which crashes deserialization of an otherwise-valid API response and forces callers to monkey-patch the SDK.

deserialize_model now attempts the normal validating construction first — so all valid data behaves exactly as before — and only on ValueError falls back to building the model tolerantly, preserving the raw value the API sent (set on the private field, bypassing the setter). Deserialization shouldn't reject values the authoritative server returns.

Verified locally: both reported values reproduce the ValueError on main and deserialize cleanly after; valid values (e.g. EIN) are unaffected. Added test_deserialize_model_tolerates_unknown_enum; full deserializer suite green (63 passed).

🤖 Generated with Claude Code

…roAPI#205, XeroAPI#206)

The Xero API can return enum values this generated SDK predates (e.g.
tax_number_type='TAXNUMBERTYPE/SSN', source_transaction_type_code='RECEIPT').
The per-attribute setters reject those with ValueError, which crashes
deserialization of an otherwise-valid response and forces callers to
monkey-patch the SDK. deserialize_model now falls back to building the model
tolerantly, preserving the raw value the API sent. Valid values are unaffected.

Adds a regression test.
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.

get_contacts tax_number_type, invalid value "TAXNUMBERTYPE/SSN"

1 participant