You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tighten read_object validation. Reject broken zlib data, malformed headers, unknown types, bad lengths, and hash mismatches with ObjectCorruptError.
Length means bytes, including for UTF-8 content.
Missing objects still raise ObjectNotFoundError.
Validate hashes before building disk paths. Accept full 40-character lowercase hex hashes. Reject other input with ObjectNotFoundError.
Make loose-object writes atomic: write a temporary file beside the destination, then rename it into place.
Clean up the temporary file on failure.
A duplicate write must validate the existing object before returning its hash.
An existing corrupt object raises ObjectCorruptError.
Add has_object(hash: str) -> bool for M4.
Use read_object. Return False only for ObjectNotFoundError.
Let corruption errors reach the caller.
Keep loose-file lookup in a private helper. Write a short docs/packfiles.md proposal covering record format, hash-to-offset lookup, and loose-file fallback. Packfile implementation starts in Week 5.
Run scripts/quality-check.sh. Open a PR linked to this issue and request a teammate review.
Tests
Round-trip empty and binary blobs, trees, and commits through a fresh store.
Corrupt the header, length, payload, and compressed stream separately.
Check Unicode byte lengths and invalid hashes.
Simulate a failed write: no partial object at the final path; retry succeeds.
Check valid duplicates, corrupt duplicates, and all three has_object outcomes.
Use tmp_path for every test, including CLI tests.
Done when
Bad objects raise the shared errors.
Failed writes leave no partial object at its final path.
M4 can check object presence through has_object.
Packfile proposal is ready for review.
Quality check passes; PR open and review requested.
Owner: @mahis1067
Files:
minigit/objects.py,tests/test_objects.py,docs/packfiles.mdDepends on: #16
Branch:
week4/m1-object-store-hardeningMake corrupt objects fail clearly. Prepare the storage code for Week 5 packfiles.
Steps
mainafter Week 3 - M1: Tree object serialization #16 merges. Keep the existing object API and byte formats.read_objectvalidation. Reject broken zlib data, malformed headers, unknown types, bad lengths, and hash mismatches withObjectCorruptError.ObjectNotFoundError.ObjectNotFoundError.ObjectCorruptError.has_object(hash: str) -> boolfor M4.read_object. ReturnFalseonly forObjectNotFoundError.docs/packfiles.mdproposal covering record format, hash-to-offset lookup, and loose-file fallback. Packfile implementation starts in Week 5.scripts/quality-check.sh. Open a PR linked to this issue and request a teammate review.Tests
has_objectoutcomes.tmp_pathfor every test, including CLI tests.Done when
has_object.