Files test: etag_survives_restart_and_changes_with_replaced_content fails on dev (500 instead of 304) #119

Closed
opened 2026-09-25 20:25:33 +00:00 by kayg · 1 comment
Owner

Context

Found during #107 (job/inline-xss). The test fails on plain dev (8a4d681, Merge job/journal-cas) without any #107 change:

cargo test -p calternal-plugin-files --lib etag_survives
thread 'tests::etag_survives_restart_and_changes_with_replaced_content' panicked at crates/plugins/files/src/lib.rs:4424:9:
assertion `left == right` failed
  left: 500
 right: 304

Cause (likely)

download in crates/plugins/files/src/lib.rs now opens the file first and takes the size from the open handle (the #98 fix: the hash, the length and the streamed bytes must describe one revision). The test sets the file mode to 0o000 and expects a cached 304 from the Index fingerprint alone, without an open. The open now fails first, and the fs error becomes a 500.

Do

Decide which behaviour is right and make code and test agree:

  • If a 304 must not need an open: answer If-None-Match from the Index before the open loop (only when the Index fingerprint still matches the path's inode), and keep the test.
  • Otherwise: change the test (no 0o000 trick) and make an unreadable file a clean 4xx or 5xx that the adversarial probe accepts, never a panic.

Acceptance: cargo test -p calternal-plugin-files passes on dev.

## Context Found during #107 (`job/inline-xss`). The test fails on plain `dev` (8a4d681, `Merge job/journal-cas`) without any #107 change: ``` cargo test -p calternal-plugin-files --lib etag_survives thread 'tests::etag_survives_restart_and_changes_with_replaced_content' panicked at crates/plugins/files/src/lib.rs:4424:9: assertion `left == right` failed left: 500 right: 304 ``` ## Cause (likely) `download` in `crates/plugins/files/src/lib.rs` now opens the file first and takes the size from the open handle (the #98 fix: the hash, the length and the streamed bytes must describe one revision). The test sets the file mode to `0o000` and expects a cached `304` from the Index fingerprint alone, without an open. The open now fails first, and the fs error becomes a 500. ## Do Decide which behaviour is right and make code and test agree: - If a `304` must not need an open: answer `If-None-Match` from the Index before the open loop (only when the Index fingerprint still matches the path's inode), and keep the test. - Otherwise: change the test (no `0o000` trick) and make an unreadable file a clean 4xx or 5xx that the adversarial probe accepts, never a panic. Acceptance: `cargo test -p calternal-plugin-files` passes on `dev`.
Author
Owner

Fixed on dev by 73084fc (Files: answer a matching If-None-Match from the Index before opening the file), which landed while this issue was being filed. Duplicate of that fix.

Fixed on dev by 73084fc (Files: answer a matching If-None-Match from the Index before opening the file), which landed while this issue was being filed. Duplicate of that fix.
kayg closed this issue 2026-09-25 20:45:38 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#119
No description provided.