Skip to content

fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526

Open
jawwad-ali wants to merge 2 commits into
github:mainfrom
jawwad-ali:fix/workflow-catalog-priority-guard
Open

fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526
jawwad-ali wants to merge 2 commits into
github:mainfrom
jawwad-ali:fix/workflow-catalog-priority-guard

Conversation

@jawwad-ali

@jawwad-ali jawwad-ali commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

The WorkflowRegistry and StepRegistry catalog-config loaders parsed priority with:

priority = int(item.get("priority", idx + 1))   # inside except (TypeError, ValueError)

missing two guards: bool is an int subclass (so priority: true was silently coerced to 1), and int(float("inf")) raises OverflowError (so priority: .inf crashed). The two _coerce_priority helpers used by catalog add had the same OverflowError gap.

Fix

Add the explicit bool check and OverflowError to both loaders, and OverflowError to both _coerce_priority helpers (they return 0 for an uncoercible existing priority rather than crashing catalog add).

Scope note: the shared CatalogStackBase loader (catalogs.py, backing extensions + integrations) and the separate PresetCatalog loader are handled in #3525. This PR covers the workflow and step catalog loaders.

Test

  • test_config_priority_bool_or_inf_rejected on both TestWorkflowCatalog/TestStepCatalog rejects priority: true/false/.inf.
  • test_add_catalog_with_existing_inf_priority on both prewrites an existing .inf entry and calls add_catalog(), asserting success + the expected new priority (fails before: add_catalog crashed with OverflowError).

🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.

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.

Pull request overview

Rejects boolean and infinite priorities in workflow and step catalog loaders while preventing catalog add from crashing on infinite existing priorities.

Changes:

  • Adds explicit boolean validation and OverflowError handling.
  • Adds regression tests for loader validation.
Show a summary per file
File Description
src/specify_cli/workflows/catalog.py Hardens priority parsing and add-catalog coercion.
tests/test_workflows.py Tests invalid boolean and infinite priorities.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment thread src/specify_cli/workflows/catalog.py
Comment thread src/specify_cli/workflows/catalog.py
Comment thread src/specify_cli/workflows/catalog.py
jawwad-ali and others added 2 commits July 17, 2026 15:36
…catalog loaders

The WorkflowRegistry and StepRegistry catalog-config loaders coerced priority
with int() inside except (TypeError, ValueError), missing two guards the base
CatalogStackBase loader already has:
- bool is an int subclass, so 'priority: true' was silently coerced to 1;
- int(float('inf')) raises OverflowError (not caught), so 'priority: .inf'
  crashed with an uncaught traceback.
Add the explicit bool check and OverflowError to both loaders, and add
OverflowError to the two _coerce_priority helpers used by 'catalog add' (they
return 0 on an uncoercible existing priority instead of crashing).

Parametrized tests on both TestWorkflowCatalog and TestStepCatalog reject
priority true/false/.inf (fail before: bool coerced to 1 / inf OverflowError).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ing priority: .inf

The workflow/step catalog priority guards added OverflowError to _coerce_priority
(the 'catalog add' fallback), but the tests only exercised get_active_catalogs().
Add tests that prewrite an existing 'priority: .inf' entry and call add_catalog()
for both WorkflowCatalog and StepCatalog, asserting the command succeeds and the
new entry gets a valid priority (inf coerced to 0, +1). Fails before: int(inf)
OverflowError crashed add_catalog.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jawwad-ali
jawwad-ali force-pushed the fix/workflow-catalog-priority-guard branch from ab203d3 to 7c2c673 Compare July 17, 2026 10:41
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.

3 participants