fix(flow): resolve sender path and inflight staging - #138
Open
robjarawan wants to merge 1 commit into
Open
Conversation
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
from
September 5, 2026 02:35
b6211bb to
14014db
Compare
Test Results376 tests 375 ✅ 1m 46s ⏱️ Results for commit 84f3f23. ♻️ This comment has been updated with latest results. |
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
from
September 5, 2026 02:53
14014db to
43486ba
Compare
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
3 times, most recently
from
September 5, 2026 03:58
8a65097 to
476da71
Compare
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
from
September 5, 2026 14:52
476da71 to
0497976
Compare
robjarawan
pushed a commit
that referenced
this pull request
Sep 5, 2026
When running sender with dry_run enabled, Flow.send skipped changing to local_dir, causing relative path checks against local_file to fail when the working directory differed from local_dir. Furthermore, inflight modes allowed directory mutations during fileOp events, performed renames on partitioned block transfers, mishandled short final inplace blocks, permitted path traversal, and failed to restore the caller working directory. Resolve local_path with realpath and enforce containment under baseDir. Defer inflight staging and rename checks to payload transfers. Support absolute and subfolder staging paths while disabling accelerated transfers for absolute paths. Ensure block transfers bypass temporary rename, prioritize inplace block offsets over inflight=None, accept short final blocks, validate write byte counts, and restore working directory. Fixes: MetPX#1772 Refs: #138
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
from
September 5, 2026 19:10
0497976 to
3d95cd9
Compare
When running sender with dry_run enabled, Flow.send skipped changing to local_dir, causing relative path checks against local_file to fail when the working directory differed from local_dir. Furthermore, inflight modes allowed directory mutations during fileOp events, performed renames on partitioned block transfers, mishandled short final inplace blocks, permitted path traversal, and failed to restore the caller working directory. Resolve local_path with realpath and enforce containment under baseDir. Defer inflight staging and rename checks to payload transfers. Support absolute and subfolder staging paths while disabling accelerated transfers for absolute paths. Ensure block transfers bypass temporary rename, prioritize inplace block offsets over inflight=None, accept short final blocks, validate write byte counts, and restore working directory. Fixes: MetPX#1772 Refs: #138
robjarawan
force-pushed
the
fix/sender-dry-run-local-dir
branch
from
September 5, 2026 19:10
3d95cd9 to
84f3f23
Compare
This was referenced Sep 6, 2026
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.
When running sender with
dry_runenabled,Flow.sendskipped changing directory tolocal_dir. Relative path existence checks againstlocal_filefailed when the daemon working directory differed fromlocal_dir, preventing test executions from completing successfully. Furthermore, staging directories were prepared duringfileOpevents, partitioned block transfers triggered invalid renames of non-existent temporary paths, short final blocks were rejected duringinplacetransfers, and non-stringinflightvalues caused unhandled exceptions.Fixes: MetPX#1772
Upstream PR: MetPX#1773
Fork Issue: #137
What this adds
Flow.sendresolveslocal_pathusingos.path.realpathand verifies thatos.path.commonpath([base_dir, local_path]) == base_dir. Any attempted path traversal outsidebase_dirlogs an error and returns-1.Flow.sendpreserves the original process working directory file descriptor prior to directory modification and restores it in afinally:block across live and dry run modes.Inflight options enforce string validation. Directory staging paths starting with
/or ending in/take precedence over file suffixes. Absolute staging paths disable accelerated transfer and are rejected on object storage backends. Staging directory creation and rename capability checks are deferred to the payload transfer section sofileOpevents (remove,rename,directory,link) bypass staging operations.Partitioned block transfers bypass staging and temporary rename steps. Inplace block transfers extract offsets and lengths from
msg['blocks']manifests, take precedence overinflight is None, and usemsg['size']as the expected written length for short final blocks. Insarracenia/transfer/sftp.py, file truncation during partial block writes is removed so out-of-order block assembly succeeds.Written byte counts returned by transfer backends are validated against
expected_lengthbefore executing renames or writing success report codes.Blast radius and rollback
This change modifies transfer staging, directory switching, and write validation logic in
sarracenia/flow/__init__.pyandsarracenia/transfer/sftp.py.Destructive operations:
cd_forcedwhen configured withinflightdirectory paths.removefileOpevents.If transfer validation fails, files remain in temporary staging paths without replacing existing target files. Rollback is accomplished by reverting the commit on the branch. Reviewers should focus on the staging directory preparation placement in
sarracenia/flow/__init__.pylines 2735-2755 and block transfer precedence in lines 2820-2850.How to verify
Execute the flow test suite:
Verify formatting and line length:
git diff origin/development..HEAD | pycodestyle --diff --max-line-length=119Evidence
Platform results