Skip to content

Conversation

@nocoding03
Copy link

@nocoding03 nocoding03 commented Nov 17, 2025

Currently, json_normalize exhibits inconsistent behavior when using non-string keys in the meta parameter:

  • meta=[12] (without record_path) - incorrectly works
  • meta=[12] (with record_path) - correctly fails with TypeError

This inconsistency violates the principle of least surprise and contradicts the documented API.

@nocoding03 nocoding03 changed the title Fix json normalize validation Fix json normalize 'meta' validation Nov 17, 2025
@nocoding03
Copy link
Author

pre-commit.ci autofix

pre-commit-ci bot and others added 3 commits November 17, 2025 10:46
Updated the _validate_meta function to accept a string or a list of strings/lists of strings as input.
@nocoding03
Copy link
Author

@rhshadrach could you please take a look at this PR?

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! It seems to me the meta argument is not expected to be large data (e.g. hundreds of entries) and so these instance checks are okay. But I'd like another eye here - cc @mroeschke

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.

BUG: pd.json_normalize has inconsistent validation for non-string keys - accepts integers in some parameter combinations but rejects in others

2 participants