Skip to content

fix(json): distinguish null from the none enum member - #762

Open
Shubham Padkonde (Shubham-Padkonde) wants to merge 1 commit into
microsoft:mainfrom
Shubham-Padkonde:fix/json-null-enum-values
Open

Shubham Padkonde (Shubham-Padkonde) wants to merge 1 commit into
microsoft:mainfrom
Shubham-Padkonde:fix/json-null-enum-values

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Overview

Preserve JSON null when parsing an enum that has a None_ = "none" member. Currently str(None) becomes "None", which takes the reserved-keyword handling path and returns the actual enum member. A missing value can therefore be mistaken for an explicitly supplied "none" value.

Return None before converting a null node to text. The wire value "none" still resolves to None_, and ordinary enum values are unchanged. Collection entries use the same correction.

Related Issue

No separate issue found. The regression is reproduced by JsonParseNode(None).get_enum_value() with an enum containing None_ = "none".

Testing Instructions

  • Install the local abstractions and JSON serialization packages and the JSON package's test dependencies.
  • From packages/serialization/json, run python -m pytest tests -q: all 200 tests pass.
  • The scalar-null and null-collection-entry regressions both fail before the fix; explicit "none" and "low" remain valid.
  • Mypy passes for all six source files; YAPF reports no changes for the edited source and new tests.

Pylint rates the source 10/10 but reports the existing suggestion-mode configuration option as unrecognized in the installed version.

@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant