Repository navigation
fix(model-store): specify UTF-8 encoding in registry read_text to prevent UnicodeDecodeError - #5881
Closed
vaibhavsrv wants to merge 1 commit into
Closed
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
…vent UnicodeDecodeError
Collaborator
|
Thanks for this contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In
ods/scripts/register-model-store.py,register()reads the existing model store registry viaregistry_path.read_text()without specifying an explicit encoding. On Python's default behavior,read_text()uses the locale-preferred encoding —cp1252on Windows,asciiin some minimal containers — rather than UTF-8. When a registry file contains non-ASCII characters in stored host paths (e.g. paths with accented characters or emoji),read_text()raises an unhandledUnicodeDecodeError, aborting model store registration even though the registry was written correctly as UTF-8.This patch adds
encoding='utf-8'to theregistry_path.read_text()call at line 50, matching the encoding used by all other JSON reads in the script and ensuring portable, platform-independent registry access.Validation
/models/café-models) as UTF-8 bytes; confirmed thatread_text()without encoding raisedUnicodeDecodeErrorin locales where the default encoding is not UTF-8.ods/tests/test_register_model_store_encoding.pypasses with exit code 0; non-ASCII paths round-trip correctly and the missing-file fallback continues to produce the default empty registry.Overlap check
.envfile-not-found guard and export prefix in compose flag resolver; zero overlap in registry read logic.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This strengthens portable JSON reading in model store registration; runtime daemon behavior, docker execution, and installed model catalogs are not altered. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #5876 at
d1f6b0b06without conflicts. Production and test diffs passed together; adjacent model store compose flags and registry contracts remain intact.Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.