{"record":{"id":"82636409de45ede1","repo":"github/spec-kit","slug":"invalid-priority-for-catalog-item-get-name-id","errorCode":null,"errorMessage":"Invalid priority for catalog '{item.get('name', idx + 1)}': expected integer, got {raw_priority!r}","messagePattern":"Invalid priority for catalog '(.+?)': expected integer, got (.+?)","errorType":"validation","errorClass":"PresetValidationError","httpStatus":null,"severity":"error","filePath":"src/specify_cli/presets/__init__.py","lineNumber":4311,"sourceCode":"        entries: List[PresetCatalogEntry] = []\n        for idx, item in enumerate(catalogs_data):\n            if not isinstance(item, dict):\n                raise PresetValidationError(\n                    f\"Invalid catalog entry at index {idx}: expected a mapping, got {type(item).__name__}\"\n                )\n            url = str(item.get(\"url\", \"\")).strip()\n            if not url:\n                continue\n            self._validate_catalog_url(url)\n            raw_priority = item.get(\"priority\", idx + 1)\n            # Reject bools explicitly: ``bool`` is a subclass of ``int`` so\n            # ``int(True)`` silently returns 1, which would let a YAML\n            # ``priority: true`` slip through as a valid priority of 1. The\n            # sibling integration-catalog reader in ``catalogs.py`` already\n            # guards this; mirror the check here so the three catalog\n            # validators stay consistent.\n            if isinstance(raw_priority, bool):\n                raise PresetValidationError(\n                    f\"Invalid priority for catalog '{item.get('name', idx + 1)}': \"\n                    f\"expected integer, got {raw_priority!r}\"\n                )\n            try:\n                priority = int(raw_priority)\n            except (TypeError, ValueError, OverflowError):\n                # OverflowError: int(float(\"inf\")) — a YAML ``priority: .inf``\n                # would otherwise escape as an uncaught traceback instead of the\n                # clean validation error (mirrors catalogs.py).\n                raise PresetValidationError(\n                    f\"Invalid priority for catalog '{item.get('name', idx + 1)}': \"\n                    f\"expected integer, got {raw_priority!r}\"\n                )\n            raw_install = item.get(\"install_allowed\", False)\n            if isinstance(raw_install, str):\n                install_allowed = raw_install.strip().lower() in (\"true\", \"yes\", \"1\")\n            else:\n                install_allowed = bool(raw_install)","sourceCodeStart":4293,"sourceCodeEnd":4329,"githubUrl":"https://github.com/github/spec-kit/blob/bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c/src/specify_cli/presets/__init__.py#L4293-L4329","documentation":"A catalog entry's 'priority' value is a YAML boolean. Because bool is a subclass of int in Python, 'priority: true' would silently become 1; the loader explicitly rejects booleans with PresetValidationError to keep the three catalog validators consistent.","triggerScenarios":"Writing 'priority: true', 'priority: false', or any YAML value parsed as a boolean for a catalog entry in the preset catalog config.","commonSituations":"User intends priority 'yes'/'on' ( YAML 1.1 treats these as booleans) meaning 'enabled'; copy-paste from a config using a boolean flag schema; YAML 1.1 parsers interpreting 'on'/'off'/'yes'/'no' as bools.","solutions":["Replace the boolean with an explicit integer priority (lower number = higher priority)","Quote the value if it was meant as text, or remove the priority key entirely (it defaults to index+1)","Avoid YAML 1.1 boolean words (yes/no/on/off) in integer fields"],"exampleFix":"# before\ncatalogs:\n  - url: https://example.com/catalog.json\n    priority: true\n\n# after\ncatalogs:\n  - url: https://example.com/catalog.json\n    priority: 1","handlingStrategy":"validation","validationCode":"for item in data[\"catalogs\"]:\n    p = item.get(\"priority\", 0)\n    if isinstance(p, bool):\n        raise ValueError(f\"priority must be int, got bool {p}\")","typeGuard":"def is_int_priority(value: object) -> bool:\n    return isinstance(value, int) and not isinstance(value, bool)","tryCatchPattern":"except PresetValidationError as e:\n    if \"Invalid priority\" in str(e) and \"True/False\" in str(e):\n        normalize_priorities_in_config(path)  # map true->1, false->last\n    raise","preventionTips":["Use only plain integers for priority","Avoid YAML 1.1 boolean words (yes/no/on/off) anywhere near numeric fields","Add a preflight check rejecting bool priorities"],"tags":["yaml","config","validation","type-coercion"],"backgroundTag":null,"analyzedSha":"bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c","analyzedAt":"2026-08-14T19:43:37.150Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}