Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/json decode error on optional str fields #27

Merged
merged 4 commits into from
Feb 10, 2024

Conversation

Tinitto
Copy link
Contributor

@Tinitto Tinitto commented Feb 10, 2024

Why

Models with optional string fields were raising orjson.JSONDecodeError errors.

orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)

Cause

The parser was attempting to parse non-JSON string like 'hi' instead of strings like '"hi"' or '{"foo": "bar"}'.
This would occur when the optional string fields actually had strings in them.

Remedy

Filter out any fields that are of type str or Optional[str] or str | None and avoid JSON-parsing their values in case their values are strings.

Thanks to @nmarusov for discovering this issue and doing the initial fixes.

Марусов Николай Леонидович and others added 4 commits July 28, 2023 11:36
@Tinitto Tinitto merged commit 38cbcf7 into master Feb 10, 2024
6 checks passed
@Tinitto Tinitto deleted the hotfix/json-decode-error-on-optional-str-fields branch February 10, 2024 08:53
@Tinitto Tinitto mentioned this pull request Feb 10, 2024
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