Guyen/develop guard code overwrite 2 - #171
Open
ggankhuy wants to merge 2 commits into
Open
Conversation
…le found in dest., force exit.
Contributor
Author
Contributor
Author
ggankhuy
marked this pull request as ready for review
August 13, 2026 14:53
ggankhuy
requested review from
Cemberk,
Rohan138,
coketaste,
gargrahul and
leconcio
as code owners
August 13, 2026 14:53
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.
Motivation
Add a pre-flight check before copying the script directory contents (
models.json, therun script, and friends) into
model_dir. If any filename collides with an existingfile in the destination, the copy aborts with an error instead of silently overwriting.
Technical Details
When a
urlis specified inmodels.json,model_diris a checked-out repository.The script directory is then copied on top of it. Because most models ship a
run.shas their default run script, a
run.shalready present in the checked-out repo getsclobbered — the model_dir repo's own version is destroyed with no warning or trace.
The guard compares each source file against the destination directory and exits with an
error on the first name match, so the overwrite can never happen unnoticed.
Resolving a collision
Rename the colliding file on one side and update the reference in
models.json. PR#46 is a one-time
demonstration of this:
run.shwas renamed torun_inference.sh, with the matchingupdate in
models.json.Test Plan
Run demo PR with the madengine branch containing this PR.
Test Result
See comment section below for negative (#171 (comment)) and positive (#171 (comment)) test case results.
Submission Checklist
Test Steps:
Negative test (case of name collision)Positive test:From:
scripts/dummy/models.json:5: "scripts": "run.sh",
To:
scripts/dummy/models.json:60: "scripts": "run_inference.sh",
27991 – personal token.