Skip to content

fix(catalogs): 'priority: .inf' yields a clean validation error instead of crashing#3525

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/catalogs-priority-inf-bool-guard
Open

fix(catalogs): 'priority: .inf' yields a clean validation error instead of crashing#3525
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/catalogs-priority-inf-bool-guard

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

A catalog config with priority: .inf crashes with an uncaught traceback:

OverflowError: cannot convert float infinity to integer

CatalogStackBase._load_catalog_config coerces the priority with int() inside except (TypeError, ValueError):

try:
    priority = int(raw_priority)
except (TypeError, ValueError):
    raise self._validation_error(... "expected integer, got {raw_priority!r}")

int(float("inf")) raises OverflowError, which isn't in that tuple — so .inf (a valid YAML float) escapes the guard as a raw traceback instead of the intended clean validation error. (The bool-is-int case is already handled just above.)

Fix

Add OverflowError to the except tuple so .inf produces the same actionable Invalid priority … expected integer error. This base loader backs all four catalog systems (bundles/extensions/presets/workflows), so the fix covers them all. Matches the sibling numeric-coercion guards in this codebase (e.g. _coerce_input).

Test

Mirrors the existing test_load_catalog_config_rejects_boolean_priority with priority: .inf — fails before (OverflowError), passes after (ValidationError naming the config file).


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

…erflowError

_load_catalog_config coerces a catalog entry's priority with int() inside
except (TypeError, ValueError). int(float('inf')) raises OverflowError, which is
not in that tuple, so a YAML 'priority: .inf' escaped as an uncaught traceback
instead of the intended 'expected integer' validation error (the bool-is-int
case is already guarded just above). Add OverflowError to the except tuple.

Test mirrors the existing rejects_boolean_priority test with priority: .inf
(fails before: OverflowError; passes after: ValidationError naming the config).

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

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

Adds clean validation for infinite priorities in shared extension/integration catalog loading.

Changes:

  • Catches OverflowError during priority conversion.
  • Adds an extension-catalog regression test for .inf.
Show a summary per file
File Description
src/specify_cli/catalogs.py Handles infinite priority conversion errors.
tests/test_extensions.py Tests .inf priority validation.

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: 1
  • Review effort level: Medium

try:
priority = int(raw_priority)
except (TypeError, ValueError):
except (TypeError, ValueError, OverflowError):
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