Skip to content

Stop crashing when a token or registration response is a JSON array - #988

Merged
w-goog merged 4 commits into
masterfrom
codegen/987-json-array-guard
Nov 2, 2026
Merged

w-goog merged 4 commits into
masterfrom
codegen/987-json-array-guard

Conversation

@w-goog

@w-goog w-goog commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #987.

OIDAuthorizationService subscripts the parsed token and registration bodies without checking that they're dictionaries, so, a proxy answering with [] borks the app down with NSInvalidArgumentException. This has been there since the first release (#863 was the same crash)!

This PR gives the callback an OIDErrorCodeServerError for a 4xx and OIDErrorCodeJSONDeserializationError for a 2xx whose body isn't an object. The new tests exercise both endpoints through a stub NSURLProtocol.

Behaviour change: a 200 with [] used to yield an empty OIDTokenResponse. It's an error now :)

@w-goog
w-goog requested a review from camden-king October 30, 2026 22:45
@w-goog
w-goog merged commit dfbb0e0 into master Nov 2, 2026
16 checks passed
@w-goog
w-goog deleted the codegen/987-json-array-guard branch November 2, 2026 21:10
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.

Crash (objectForKeyedSubscript: on NSArray) when the token endpoint returns a JSON array body

2 participants