fix: avoid paths-only feature context writes#3053
Conversation
|
Please separate out in 3 PRs. Thanks! |
99577f8 to
1c89df3
Compare
|
Thanks for this. The fix direction is right — 1. Reframe the rationale. The PR/issue describes 2. Drop the new
That keeps it self-contained and removes the leak. (If there's a strong reason to keep the env var, the PS side at least needs to scope/unset it in a |
1c89df3 to
072c69d
Compare
|
Addressed the review feedback in the latest update:
Validation:
AI disclosure: this response was prepared by Codex (GPT-5) acting as an AI coding agent on behalf of @luohui1. |
072c69d to
401cf91
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Prevents check-prerequisites in --paths-only / -PathsOnly mode from persisting feature-directory overrides into .specify/feature.json, keeping paths-only behavior read-only as documented (closes #3025).
Changes:
- Add “no-persist” capability to Bash
get_feature_pathsand PowerShellGet-FeaturePathsEnv. - Update Bash/PowerShell
check-prerequisitesentrypoints to use no-persist path resolution in paths-only mode. - Add regression tests ensuring paths-only does not rewrite
.specify/feature.json.
Show a summary per file
| File | Description |
|---|---|
| tests/test_check_prerequisites_paths_only.py | Adds regression coverage ensuring paths-only does not mutate .specify/feature.json (Bash + PowerShell). |
| scripts/powershell/common.ps1 | Adds -NoPersist switch to avoid saving feature.json in paths-only mode. |
| scripts/powershell/check-prerequisites.ps1 | Routes paths-only mode through Get-FeaturePathsEnv -NoPersist. |
| scripts/bash/common.sh | Adds --no-persist flag to skip _persist_feature_json during path resolution. |
| scripts/bash/check-prerequisites.sh | Uses get_feature_paths --no-persist when --paths-only is set. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 4
| """--paths-only must not rewrite .specify/feature.json when env differs.""" | ||
| common = (prereq_repo / ".specify" / "scripts" / "bash" / "common.sh").read_text( | ||
| encoding="utf-8" | ||
| ) | ||
| script_text = ( | ||
| prereq_repo / ".specify" / "scripts" / "bash" / "check-prerequisites.sh" | ||
| ).read_text(encoding="utf-8") | ||
| assert "SPECIFY_NO_PERSIST_FEATURE_JSON" not in common | ||
| assert "get_feature_paths --no-persist" in script_text |
| if $PATHS_ONLY; then | ||
| _paths_output=$(get_feature_paths --no-persist) || { echo "ERROR: Failed to resolve feature paths" >&2; exit 1; } | ||
| else | ||
| _paths_output=$(get_feature_paths) || { echo "ERROR: Failed to resolve feature paths" >&2; exit 1; } | ||
| fi |
| local no_persist=false | ||
| if [[ "${1:-}" == "--no-persist" ]]; then | ||
| no_persist=true | ||
| fi |
| if [[ "$no_persist" == "false" ]]; then | ||
| _persist_feature_json "$repo_root" "$SPECIFY_FEATURE_DIRECTORY" | ||
| fi |
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback
Description
Closes #3025 by preventing
check-prerequisites --paths-only/-PathsOnlyfrom mutating.specify/feature.jsonwhile it is only resolving paths.SPECIFY_FEATURE_DIRECTORYremains an explicit feature-directory override. Normal command execution still persists that override through.specify/feature.json, so future sessions without the environment variable continue to work. The no-write behavior is scoped specifically to paths-only mode because that mode is documented as read-only path resolution.Testing
uv run specify --helpuv sync && uv run pytestAdditional validation after addressing review feedback:
uv run --extra test python -m pytest tests/test_check_prerequisites_paths_only.py tests/test_setup_plan_feature_json.py tests/test_timestamp_branches.py::TestFeatureDirectoryResolution -q- 8 passed, 12 skippeduvx ruff check tests/test_check_prerequisites_paths_only.py- passeduvx ruff format --check tests/test_check_prerequisites_paths_only.py- passedgit diff --check- passedManual test results
Agent: Codex (GPT-5) | OS/Shell: Windows 11 / PowerShell 7.5.4
.specify/scripts/bash/check-prerequisites.sh --json --paths-only.specify/feature.jsonbehavior..specify/scripts/powershell/check-prerequisites.ps1 -Json -PathsOnly.specify/feature.jsonbehavior.AI Disclosure
This PR was implemented by Codex (GPT-5) acting as an AI coding agent on behalf of @luohui1. The agent read the repository contribution/security/code-of-conduct docs and issue templates, inspected the relevant code paths, implemented the changes, ran the validation listed above, and prepared this PR description.