Skip to content

fix json_encode to handle non-string dict keys#10265

Open
Mr-Neutr0n wants to merge 1 commit intodetermined-ai:mainfrom
Mr-Neutr0n:fix-json-encode-bytes-keys
Open

fix json_encode to handle non-string dict keys#10265
Mr-Neutr0n wants to merge 1 commit intodetermined-ai:mainfrom
Mr-Neutr0n:fix-json-encode-bytes-keys

Conversation

@Mr-Neutr0n
Copy link
Copy Markdown

When profiling is enabled, some metrics dicts end up with bytes keys (from system-level profiling data). The jsonable() helper in util.json_encode was recursing into dict values but passing keys through unchanged, so json.dumps would blow up with TypeError: keys must be str, int, float, bool or None, not bytes.

The fix is one line — apply jsonable() to dict keys too, not just values. This way bytes keys get decoded to strings the same way bytes values already do.

Also added a test for this case.

Fixes #10263

the jsonable() helper was only converting dict values but not keys,
so bytes keys (e.g. from profiling metrics) would cause a TypeError
in json.dumps. now both keys and values get converted.

fixes determined-ai#10263
@Mr-Neutr0n Mr-Neutr0n requested a review from a team as a code owner February 15, 2026 15:35
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 15, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Mr-Neutr0n on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

After we approve your CLA, we will update the contributors list (private) and comment @cla-bot[bot] check to rerun the check.

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] JSON Serialization issue when profiling is enabled

1 participant