Repository navigation
fix(files): store read_only as a string so Redis metadata writes succeed - #77
Merged
Merged
Conversation
3.7.0 added read_only to the file-metadata dict as a raw Python bool, but redis-py's Encoder only accepts bytes/str/int/float and raises DataError on bool (checked before int, despite bool being an int subclass) - which fails the ENTIRE hset. In production every upload and cross-session consolidation logged 'Failed to store file metadata' / 'Failed to consolidate cross-session file' and the file's metadata was never written, breaking later mounts and downloads of those files. Store 'true'/'false' following the file's existing convention (size and created_at are also stringly-stored and converted on read), and parse it back to bool in _get_file_metadata. The new tests enforce redis-py's real type contract on the hset mapping - the permissive AsyncMock that let this slip now rejects exactly what redis rejects - and both fail on the pre-fix code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🎉 This PR is included in version 3.7.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
Background: found in production ~10 minutes after the 3.7.0 rollout - every upload and cross-session consolidation logs
Failed to store file metadata: Invalid input of type: 'bool'and the file's metadata never lands in Redis, which breaks later mounts and downloads of those files (executions themselves are unaffected). Root cause: 3.7.0 put the newread_onlyfield into the metadata dict as a raw Python bool, and redis-py's Encoder raises DataError on bool (it checks bool before int, despite bool being an int subclass), failing the entire hset.read_onlyas"true"/"false", matching the file's existing convention (size and created_at are also stringly-stored and converted on read), and parse it back to bool in_get_file_metadataAsyncMockthat let this slip now rejects exactly what redis rejectsThis is exactly the class of gap the AGENTS.md testing note warns about ("unit tests mock Kubernetes/Redis/MinIO") - the mock accepted a value the real client never would.
Testing
Both new tests fail on the pre-fix code and pass with it:
Full suite: 1628 passed, ruff + ty + format clean. Production evidence from the 3.7.0 deploy (developer-platform, last 10m): 4 metadata-store failures across 2 files, 6/6 executions completed.
Review Strategy
The read path was partially masked before this - pydantic happened to coerce the hgetall string into the right bool - so the visible damage was the failed hset, not a wrong read_only value. Once merged and released as 3.7.1, ai-infra needs the image_tag/chart bump to pick it up.
🤖 Generated with Claude Code