Repository navigation
fix(workflows): use project file mode on fresh URL installs - #5613
Open
Gaoshou101 wants to merge 1 commit into
Open
Gaoshou101 wants to merge 1 commit into
Gaoshou101 wants to merge 1 commit into
Conversation
When installing a single-file workflow from an HTTP(S) URL or `--from`, the downloaded bytes are written to a `tempfile.NamedTemporaryFile` (mode `0600`). Previously `_validate_and_install_local()` copied that temp file's `0600` mode onto the newly installed `workflow.yml`, leaving fresh URL installs `0600` instead of respecting the process umask like catalog installs. Pass `preserve_source_mode=False` for URL downloads so fresh installs stage with `use_project_file_mode=True` while reinstalls still preserve the existing `workflow.yml` mode via `_commit_workflow_file()`. Fixes github#5077 Assisted-by: Hermes-Agent (model: gemini-4-hydrogen-xhigh, autonomous)
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the changes aligning fresh URL workflow install permissions with normal project file modes.
No open issues 🎉
What changed in this PR
Fixes #5077 by making fresh single-file workflow URL installs use the normal project file mode, consistent with catalog installs.
Changes:
- Apply the process umask to fresh URL installs instead of inheriting the download temporary file’s restrictive permissions.
- Preserve existing destination permissions on reinstall and retain source permissions for local installs.
- Add regression tests for direct URL and
--frominstalls, plus permission preservation on reinstall.
The PR reports passing before-and-after regression checks; tests were not independently rerun here.
| File | Description |
|---|---|
tests/specify_cli/workflows/test_command_add.py |
Adds URL-install and reinstall permission regression tests. |
src/specify_cli/workflows/command_add.py |
Separates URL download permissions from local source-mode preservation. |
Review effort: Balanced (adaptive)
This branch has not been deployed
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.
Description
Fixes #5077
When installing a single-file workflow via
specify workflow add <url>orspecify workflow add <id> --from <url>, the downloaded YAML is written to atempfile.NamedTemporaryFile(created with restrictive mode0o600)._validate_and_install_local()then copiedsource_mode(0o600) onto the staged file and installed.specify/workflows/<id>/workflow.ymlwith0o600, unlike catalog installs which respect the process umask on fresh install (e.g.0o644under0o022).Changes
src/specify_cli/workflows/command_add.py:preserve_source_mode: bool = Trueto_validate_and_install_local().preserve_source_mode=False, stage withuse_project_file_mode=not dest_file.exists()and skip copying the temporary file's mode bits so fresh installs follow the process umask, while reinstalls continue preserving the existing destination file's mode via_commit_workflow_file().preserve_source_mode=Falsefrom the URL download branch (tmp_path).tests/specify_cli/workflows/test_command_add.py:test_add_url_fresh_install_uses_project_file_mode(parametrized over direct URL and--fromURL; failed before fix with0o600 != 0o644, passes after).test_add_url_reinstall_preserves_existing_file_mode(verifies0o640on an existingworkflow.ymlis preserved on URL reinstall).Scope & Limitations
_validate_and_install_local(); local file/directory installs keeppreserve_source_mode=True, and archive URL installs go through_install_workflow_package().Testing
Red before:
.venv/bin/pytest tests/specify_cli/workflows/test_command_add.py -k "uses_project_file_mode or test_add_url_reinstall_preserves_existing_file_mode" -vfailed on bothtest_add_url_fresh_install_uses_project_file_mode[url]and[from_url](0o600instead of0o644).Green after:
.venv/bin/pytest tests/specify_cli/workflows/test_command_add.py -v-> 122 passed in 4.27s (re-run after wrapping long line: 122 passed in 4.50s).venv/bin/pytest tests/specify_cli/workflows/test_command_update.py -q-> 39 passed in 1.41s.venv/bin/pytest tests/specify_cli/workflows/ -q-> 1454 passed, 30 skipped in 65.71s.venv/bin/specify --help-> exit 0git diff --check-> exit 0Tested locally with
.venv/bin/specify --helpRan relevant existing tests with
.venv/bin/pytest tests/specify_cli/workflows/ -qTested with a sample project (covered via
CliRunner+ temporary project fixture)AI Disclosure
AI disclosure: Assisted by Hermes-Agent (
gemini-4-hydrogen-xhigh, autonomous mode; independent pre-submission code review bygpt-6.2-sol) for root-cause analysis, minimal patch generation, and regression test creation.