fix(scripts): fall through to grep/sed when python3 is a broken stub in feature.json parser#3312
Open
Quratulain-bilal wants to merge 1 commit into
Conversation
…in feature.json parser read_feature_json_feature_directory picked its json parser by availability (if jq / elif python3 / else grep-sed). on windows `python3` usually resolves to the microsoft store app execution alias stub: it satisfies `command -v` but fails at runtime (exit 49). the elif selected it, the runtime failure was swallowed to _fd='', and the grep/sed last resort was never reached - so a valid .specify/feature.json read as empty and every setup-plan / setup-tasks / check-prerequisites call errored with "Feature directory not found" right after a successful `specify init --script sh`. change selection from availability to parse success: try jq, then python3 only if still empty, then grep/sed only if still empty. a parser that exists but produces nothing now falls through instead of terminating the chain. the write path (_persist_feature_json) already uses jq-or-printf with no python3, so it was unaffected; only the read path needed this. add a regression test that puts a python3 stub (exit 49, like the store alias) first on PATH and asserts setup-plan.sh still resolves the feature via the grep/sed fallback. fixes github#3304
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.
fixes #3304
what
read_feature_json_feature_directoryinscripts/bash/common.shchose its JSON parser by availability:on windows
python3usually resolves to the microsoft store app execution alias stub. it satisfiescommand -v python3but fails at runtime (exit 49, "Python was not found..."). theelifselected it, the failure was swallowed to_fd='', and the grep/sed last resort was never reached. so a valid.specify/feature.jsonread as empty, and every script that resolves a feature this way (setup-plan.sh,setup-tasks.sh,check-prerequisites.sh, ...) errored withFeature directory not foundright after a successfulspecify init --script sh— as reported.how
select by parse success, not availability: try jq, then python3 only if the result is still empty, then grep/sed only if still empty. a parser that exists but yields nothing now falls through instead of ending the chain.
the write path (
_persist_feature_json) already uses jq-or-printfwith no python3, so it wasn't affected; only the read path needed this.verified
reproduced end-to-end with git-for-windows bash, a stub
python3(exit 49) first on PATH, and no jq:bash setup-plan.sh --json→ERROR: Feature directory not found(exit 1)plan.md(exit 0), emits the expected JSON pathsadded
test_setup_plan_survives_broken_python3_stub: writes apython3stub that exits 49, prepends it to PATH, and assertssetup-plan.shstill succeeds via the grep/sed fallback. it uses the same@requires_bashharness as the existing tests in that file (skips where a suitable bash isn't present).