Skip to content

fix(workflows): use project file mode on fresh URL installs - #5613

Open
Gaoshou101 wants to merge 1 commit into
github:mainfrom
Gaoshou101:fix/5077-workflow-url-file-mode
Open

Gaoshou101 wants to merge 1 commit into
github:mainfrom
Gaoshou101:fix/5077-workflow-url-file-mode

Conversation

@Gaoshou101

Copy link
Copy Markdown

Description

Fixes #5077

When installing a single-file workflow via specify workflow add <url> or specify workflow add <id> --from <url>, the downloaded YAML is written to a tempfile.NamedTemporaryFile (created with restrictive mode 0o600). _validate_and_install_local() then copied source_mode (0o600) onto the staged file and installed .specify/workflows/<id>/workflow.yml with 0o600, unlike catalog installs which respect the process umask on fresh install (e.g. 0o644 under 0o022).

Changes

  • src/specify_cli/workflows/command_add.py:
    • Add preserve_source_mode: bool = True to _validate_and_install_local().
    • When preserve_source_mode=False, stage with use_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().
    • Pass preserve_source_mode=False from the URL download branch (tmp_path).
  • tests/specify_cli/workflows/test_command_add.py:
    • Add test_add_url_fresh_install_uses_project_file_mode (parametrized over direct URL and --from URL; failed before fix with 0o600 != 0o644, passes after).
    • Add test_add_url_reinstall_preserves_existing_file_mode (verifies 0o640 on an existing workflow.yml is preserved on URL reinstall).

Scope & Limitations

  • Only affects single-file YAML URL downloads routed through _validate_and_install_local(); local file/directory installs keep preserve_source_mode=True, and archive URL installs go through _install_workflow_package().
  • Targeted workflow test suite and CLI smoke check were run rather than the entire non-workflow test suite.

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" -v failed on both test_add_url_fresh_install_uses_project_file_mode[url] and [from_url] (0o600 instead of 0o644).

  • 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 0
    • git diff --check -> exit 0
  • Tested locally with .venv/bin/specify --help

  • Ran relevant existing tests with .venv/bin/pytest tests/specify_cli/workflows/ -q

  • Tested with a sample project (covered via CliRunner + temporary project fixture)

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: Assisted by Hermes-Agent (gemini-4-hydrogen-xhigh, autonomous mode; independent pre-submission code review by gpt-6.2-sol) for root-cause analysis, minimal patch generation, and regression test creation.

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)
@Gaoshou101
Gaoshou101 requested a review from mnriem as a code owner November 29, 2026 04:49
Copilot AI adaptive review requested due to automatic review settings November 29, 2026 04:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 --from installs, 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: workflow add <url> installs workflow.yml with mode 0600, while a catalog install uses the project file mode

2 participants