Skip to content

fix(workflows): append catalog sources after implicit priorities - #5123

Open
JRHU0048 wants to merge 1 commit into
github:mainfrom
JRHU0048:fix/5074-catalog-implicit-priority
Open

JRHU0048 wants to merge 1 commit into
github:mainfrom
JRHU0048:fix/5074-catalog-implicit-priority

Conversation

@JRHU0048

Copy link
Copy Markdown

Description

Fixes #5074.

Adding a workflow or step catalog to three sources with omitted priorities currently changes their effective order from first, second, third to first, added, second, third. The config reader assigns omitted priorities from their one-based positions, but add_catalog treated them as zero and assigned the new source priority 1. This can change which source supplies a shared workflow or step ID.

Both add_catalog implementations now use the reader's one-based default when deriving the maximum existing priority. The example produces priority 4 and order first, second, third, added. Explicit priorities, numeric-string coercion, the existing malformed-priority fallback, and the existing source records retain their behavior.

Testing

  • Installed dependencies with uv sync --extra test and checked this worktree's .venv/Scripts/specify --help.
  • Ran existing tests through this worktree's own virtualenv.
  • Exercised both affected CLI command families in a disposable sample project.

Windows, Python 3.12.7:

  • The eight new domain cases cover omitted, mixed, explicit numeric-string, and negative priorities. Before the fix: 4 failed, 4 passed. After the fix: 8 passed. They also verify that existing source records are not rewritten.
  • .venv/Scripts/python -m pytest tests/specify_cli/workflows/catalog tests/specify_cli/workflows/step/catalog tests/test_workflows.py -k 'Catalog or catalog' -q: 145 passed, 692 deselected.
  • With PYTHONUTF8=1, .venv/Scripts/python -m pytest tests/specify_cli/workflows tests/test_workflows.py -n 2 -q: 1474 passed, 68 skipped, 35 failed. All 35 failing nodes also fail in a separate, unmodified 67e0f72 worktree with its own virtualenv: 34 fail while creating symlinks (WinError 1314), and one requires network access unavailable in the local sandbox.
  • The full suite was attempted with UTF-8 mode and -n 2 --maxfail=10: 1705 passed, 240 skipped, 20 failed before the xdist failure limit stopped the run. All 20 failing nodes also fail on the unmodified baseline: Windows path-length/symlink limitations and unavailable network access. The full suite is not claimed to pass or complete locally.
  • uvx ruff@0.15.0 check src tests: passed. git diff --check: passed.
  • The installed working-tree CLI was exercised from a temporary path containing Chinese characters and spaces. Both catalog families add the fourth source at priority 4, list it last, leave repeated additions unchanged, and reject a non-localhost HTTP URL without modifying the config.

Test selection reasoning

Changed behavior Affects Validation
Workflow catalog add_catalog specify workflow catalog add; resulting source precedence New domain cases, existing catalog suite, sample add/list
Step catalog add_catalog specify workflow step catalog add; resulting source precedence Mirrored domain cases, existing catalog suite, sample add/list

The changed methods are called by the catalog-add CLI handlers. Command templates do not invoke these methods; the sample exercises the affected CLI operations directly.

AI Disclosure

  • I did not use AI assistance for this contribution.
  • I did use AI assistance.

AI disclosure: OpenAI Codex (GPT-6), operating autonomously at JRHU0048's request, investigated the existing report, generated the fix and tests, executed automated checks and CLI verification, reviewed the diff, and drafted this PR. A more specific model variant and reasoning-effort setting are not exposed to the agent. This disclosure does not claim personal human line-by-line review or testing.

Use the config parser's one-based defaults when deriving the priority of a
new workflow or step catalog source. Add regression coverage for omitted,
mixed, explicit numeric-string, and negative priorities without rewriting
the existing entries.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
@JRHU0048
JRHU0048 requested a review from mnriem as a code owner October 26, 2026 07:26
@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Oct 26, 2026
@mnriem
mnriem requested a max review from Copilot October 26, 2026 14:16

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

Both localized fixes match their config readers’ defaults and have focused regression coverage with reported before-and-after evidence.

No open issues 🎉

What changed in this PR

Fixes #5074 by making newly added workflow and step catalog sources follow existing sources when priorities are omitted, preserving Specify CLI’s catalog precedence.

Changes:

  • Use the config readers’ one-based defaults when calculating the next source priority.
  • Add mirrored regression tests for implicit, mixed, explicit numeric-string, and negative priorities, including checks that existing source records remain unchanged.

Validation relies on the reported before-and-after results; tests were not rerun here.

File Description
tests/​specify_cli/​workflows/​step/​catalog/​test_domain.py Tests step catalog ordering and preservation of existing records.
tests/​specify_cli/​workflows/​catalog/​test_domain.py Tests workflow catalog ordering and preservation of existing records.
src/​specify_cli/​workflows/​step/​catalog/​_domain.py Aligns new step catalog priorities with reader defaults.
src/​specify_cli/​workflows/​catalog/​_domain.py Aligns new workflow catalog priorities with reader defaults.

Review effort: Max

@mnriem

mnriem commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Please address test & lint errors

@mnriem mnriem added the author-awaiting Waiting on author response label Oct 26, 2026

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

author-awaiting Waiting on author response triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: catalog add gives the new catalog the same priority as the first existing catalog when priorities are implicit

3 participants