Skip to content

fix(files): store read_only as a string so Redis metadata writes succeed - #77

Merged
aron-muon merged 1 commit into
mainfrom
fix/redis-bool-read-only
Sep 16, 2026
Merged

aron-muon merged 1 commit into
mainfrom
fix/redis-bool-read-only

Conversation

@aron-muon

Copy link
Copy Markdown
Owner

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 new read_only field 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.

  • stored read_only as "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_metadata
  • added tests that enforce redis-py's real type contract on the hset mapping - the permissive AsyncMock that let this slip now rejects exactly what redis rejects

This 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:

main:   FAILED test_store_uploaded_file_metadata_is_redis_encodable[True-true]
        FAILED test_store_uploaded_file_metadata_is_redis_encodable[False-false]
fixed:  54 passed

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

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>
@aron-muon
aron-muon merged commit 08e77c0 into main Sep 16, 2026
32 checks passed
@aron-muon
aron-muon deleted the fix/redis-bool-read-only branch September 16, 2026 23:17
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.7.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant