Skip to content

fix(storage): reject flushing lazy source step - #530

Merged
SunnyHaze merged 1 commit into
mainfrom
fix/lazy-storage-flush-source-guard
Sep 10, 2026
Merged

SunnyHaze merged 1 commit into
mainfrom
fix/lazy-storage-flush-source-guard

Conversation

@SunnyHaze

Copy link
Copy Markdown
Collaborator

Summary

Prevent LazyFileStorage.flush_step() from flushing step 0 or negative steps.

Step 0 represents the original input source rather than a writable cache output. Explicitly flushing it could serialize the source using cache_type and replace the original file, potentially changing its format or contents.

Changes

  • Reject flush_step(step) when step <= 0 with a detailed ValueError.
  • Explain in the error message:
    • why step 0 cannot be flushed;
    • how flushing it could damage the source file;
    • that only positive output steps buffered by write() are valid.
  • Add a regression test confirming that:
    • flush_step(0) raises the expected error;
    • the original source file remains byte-for-byte unchanged.
  • Keep flushing behavior for positive output steps unchanged.

Context

PR #527 protected source files from automatic flush_all() calls by limiting them to dirty output steps. This follow-up closes the remaining explicit flush_step(0) path without expanding into a broader storage lifecycle refactor.

@SunnyHaze
SunnyHaze merged commit 42763fc into main Sep 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant