{"record":{"id":"f3bbed55bf647fbe","repo":"gastownhall/beads","slug":"invalid-priority-q-expected-0-4-or-p0-p4-not-wo","errorCode":null,"errorMessage":"invalid priority %q (expected 0-4 or P0-P4, not words like high/medium/low)","messagePattern":"invalid priority %q \\(expected 0-4 or P0-P4, not words like high/medium/low\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/validation/bead.go","lineNumber":50,"sourceCode":"func ParseIssueType(content string) (types.IssueType, error) {\n\t// Normalize to support aliases like \"enhancement\" -> \"feature\"\n\tissueType := types.IssueType(strings.TrimSpace(content)).Normalize()\n\n\t// Use the canonical IsValid() from types package\n\tif !issueType.IsValid() {\n\t\treturn types.TypeTask, fmt.Errorf(\"invalid issue type: %s\", content)\n\t}\n\n\treturn issueType, nil\n}\n\n// ValidatePriority parses and validates a priority string.\n// Returns the parsed priority (0-4) or an error if invalid.\n// Supports both numeric (0-4) and P-prefix format (P0-P4).\nfunc ValidatePriority(priorityStr string) (int, error) {\n\tpriority := ParsePriority(priorityStr)\n\tif priority == -1 {\n\t\treturn -1, fmt.Errorf(\"invalid priority %q (expected 0-4 or P0-P4, not words like high/medium/low)\", priorityStr)\n\t}\n\treturn priority, nil\n}\n\n// ValidateIDFormat validates that an ID has the correct format.\n// Supports: prefix-number (bd-42), prefix-hash (bd-a3f8e9), or hierarchical (bd-a3f8e9.1)\n// Also supports hyphenated prefixes like \"bead-me-up-3e9\" or \"web-app-abc123\".\n// Returns the prefix part or an error if invalid.\nfunc ValidateIDFormat(id string) (string, error) {\n\tif id == \"\" {\n\t\treturn \"\", nil\n\t}\n\n\t// Must contain hyphen\n\tif !strings.Contains(id, \"-\") {\n\t\treturn \"\", fmt.Errorf(\"invalid ID format '%s' (expected format: prefix-hash or prefix-hash.number, e.g., 'bd-a3f8e9' or 'bd-a3f8e9.1')\", id)\n\t}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/validation/bead.go#L32-L68","documentation":"ValidatePriority parses a priority string supporting numeric 0-4 and P-prefixed P0-P4 forms. It returns this error when ParsePriority yields -1, i.e. the string is not a number in range after optional P-prefix stripping — most commonly because word forms like \"high\"/\"medium\"/\"low\" were used, which the parser deliberately does not accept.","triggerScenarios":"Calling validation.ValidatePriority with \"high\", \"low\", \"critical\", \"5\", \"-1\", \"p9\", \"\", or any non-numeric text. Note the parser strips a leading P/p then requires Sscanf %d with 0<=p<=4, so \"P0\"-\"P4\" and \"0\"-\"4\" pass; everything else fails.","commonSituations":"Migrating from trackers that use word priorities (GitHub labels high/medium/low); users typing \"high\" in a commit message or import file; shell scripts passing \"P5\" out of habit from other tools; localization producing non-ASCII digits.","solutions":["Convert word priorities to numbers: critical->0/P0, high->1/P1, medium->2/P2, low->3/P3, backlog->4/P4","Pass a plain integer 0-4 or P0-P4 string","Pre-map word values in your import/export script before calling ValidatePriority"],"exampleFix":"// before\np, err := validation.ValidatePriority(\"high\") // invalid\n// after\np, err := validation.ValidatePriority(\"P1\") // or \"1\"","handlingStrategy":"validation","validationCode":"func validPriority(s string) bool {\n    s = strings.TrimSpace(s)\n    if len(s) == 2 && strings.EqualFold(s[:1], \"P\") { s = s[1:] }\n    n, err := strconv.Atoi(s)\n    return err == nil && n >= 0 && n <= 4\n}","typeGuard":null,"tryCatchPattern":"p, err := validation.ValidatePriority(raw)\nif err != nil {\n    return fmt.Errorf(\"%w; map high/medium/low to 1/2/3 yourself\", err)\n}","preventionTips":["Always use numeric or P0-P4 forms in scripts and imports","Maintain a word->number map for migrating from GitHub/Jira labels","Validate priority fields at the boundary of your tooling before calling beads","Remember the range is 0-4 only; values like 5 or P5 are rejected"],"tags":["validation","priority","input","go"],"backgroundTag":"invalid-priority-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}