github/spec-kit · error · PresetValidationError
Priority must be a positive integer (1 or higher)
Error message
Priority must be a positive integer (1 or higher)
What it means
PresetManager.install_from_directory validates the resolution priority argument up front: priority must be >= 1 (lower number = higher precedence, default 10). Zero, negative numbers, or any value below 1 raise PresetValidationError before the manifest is even read.
Source
Thrown at src/specify_cli/presets/__init__.py:3558
) -> PresetManifest:
"""Install preset from a local directory.
Args:
source_dir: Path to preset directory
speckit_version: Current spec-kit version
priority: Resolution priority (lower = higher precedence, default 10)
force: If True and the preset is already installed, remove it first
Returns:
Installed preset manifest
Raises:
PresetValidationError: If manifest is invalid or priority is invalid
PresetCompatibilityError: If pack is incompatible
"""
# Validate priority
if priority < 1:
raise PresetValidationError("Priority must be a positive integer (1 or higher)")
manifest_path = source_dir / "preset.yml"
manifest = PresetManifest(manifest_path)
self.check_compatibility(manifest, speckit_version)
if self.registry.is_installed(manifest.id):
if not force:
raise PresetError(
f"Preset '{manifest.id}' is already installed. "
f"Use 'specify preset remove {manifest.id}' first."
)
self.remove(manifest.id)
dest_dir = self.presets_dir / manifest.id
if dest_dir.exists():
shutil.rmtree(dest_dir)
View on GitHub (pinned to bf88c9f9a8)
Solutions
- Pass priority=1 for maximum precedence; 10 is the conventional default.
- Clamp user/automation input before calling: `priority = max(1, int(priority))`.
- Use None-checks for 'unset' rather than 0.
Example fix
# before manager.install_from_directory(src, ver, priority=0) # after manager.install_from_directory(src, ver, priority=1)
Defensive patterns
Strategy: validation
Validate before calling
priority = max(1, int(priority)) manager.install_from_directory(source_dir, speckit_version, priority=priority)
Type guard
def is_valid_priority(p) -> bool:
return isinstance(p, int) and not isinstance(p, bool) and p >= 1 Try / catch
try:
manager.install_from_directory(src, ver, priority=p)
except PresetValidationError as e:
if "Priority" in str(e):
p = 10 # fall back to the conventional default
manager.install_from_directory(src, ver, priority=p) Prevention
- Priority starts at 1 (highest precedence); default is 10.
- Do not use 0 as a 'highest' or 'unset' sentinel.
- Clamp external/automation inputs at the boundary: max(1, int(x)).
When it happens
Trigger: Calling install_from_directory(source_dir, speckit_version, priority=0) or priority=-5 programmatically, or a CLI/automation layer passing an unvalidated user-supplied number.
Common situations: Treating priority as 0-indexed (like array ranks), using 0 as a sentinel for "highest", or computing priority from an arithmetic expression that can go negative.
Related errors
- Catalog source '{source_id}' is missing its 'priority'.
- Catalog source '{source_id}' has a non-integer priority: {pr
- provides.{kind} priority must be an integer, got {raw!r}.
- Invalid strategy value: must be a string, got {type(strategy
- Invalid strategy '{strategy}': must be one of {sorted(VALID_
AI-assisted analysis of github/spec-kit@bf88c9f9a8 (2026-08-14).
Data as JSON: /api/errors/b744f4e94152b3ee.
Report an issue: GitHub.