{"record":{"id":"6cce9b918fbf0245","repo":"gastownhall/beads","slug":"prefix-mismatch-database-uses-s-allowed-s-6cce9b","errorCode":null,"errorMessage":"prefix mismatch: database uses '%s-' (allowed: %s) but ID '%s' doesn't match any allowed prefix (use --force to override)","messagePattern":"prefix mismatch: database uses '(.+?)-' \\(allowed: (.+?)\\) but ID '(.+?)' doesn't match any allowed prefix \\(use --force to override\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/validation/bead.go","lineNumber":164,"sourceCode":"\tif strings.HasPrefix(id, dbPrefix+\"-\") {\n\t\treturn nil\n\t}\n\n\t// Check if ID starts with any allowed prefix\n\tif allowedPrefixes != \"\" {\n\t\tfor _, allowed := range strings.Split(allowedPrefixes, \",\") {\n\t\t\tallowed = strings.TrimSpace(allowed)\n\t\t\t// Normalize: remove trailing - if present (we add it for matching)\n\t\t\tallowed = strings.TrimSuffix(allowed, \"-\")\n\t\t\tif allowed != \"\" && strings.HasPrefix(id, allowed+\"-\") {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build helpful error message\n\tif allowedPrefixes != \"\" {\n\t\treturn fmt.Errorf(\"prefix mismatch: database uses '%s-' (allowed: %s) but ID '%s' doesn't match any allowed prefix (use --force to override)\",\n\t\t\tdbPrefix, allowedPrefixes, id)\n\t}\n\treturn fmt.Errorf(\"prefix mismatch: database uses '%s-' but ID '%s' doesn't match (use --force to override)\", dbPrefix, id)\n}\n","sourceCodeStart":146,"sourceCodeEnd":169,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/validation/bead.go#L146-L169","documentation":"ValidateIDPrefixAllowed checks a full issue ID against the database prefix and an allowed_prefixes list (matching on prefix+'-' boundaries, which handles multi-hyphen prefixes like hq-cv). When an allowed list is configured and the ID starts with none of the allowed prefixes, it returns this message with the DB prefix, allowed list, offending ID, and the --force escape hatch.","triggerScenarios":"Calling ValidateIDPrefixAllowed with an ID like \"web-abc123\" where dbPrefix is \"bd\" and allowedPrefixes is e.g. \"hq-cv,hn\", and the ID starts with none of \"bd-\", \"hq-cv-\", \"hn-\", force=false.","commonSituations":"Cross-posting issues between repos with different prefixes; a typo in the ID; a team's prefix missing from allowed_prefixes after a re-org; external references (e.g. GH#123 style) passed where a beads ID is required.","solutions":["Use an ID whose prefix is in the allowed list (or the DB prefix)","Add the ID's prefix to allowed_prefixes if it is legitimately part of this database","Pass force=true / --force if the foreign-prefix ID is intentional (e.g. cross-references)","Verify the ID is not a different tracker's identifier mistakenly supplied"],"exampleFix":"// before\nerr := validation.ValidateIDPrefixAllowed(\"gh-123\", \"bd\", \"hq-cv\", false) // mismatch\n// after\nerr := validation.ValidateIDPrefixAllowed(\"hq-cv-123\", \"bd\", \"hq-cv\", false)\n// or: validation.ValidateIDPrefixAllowed(\"gh-123\", \"bd\", \"hq-cv\", true) // intentional override","handlingStrategy":"validation","validationCode":"func idPrefixAllowed(id, dbPrefix, allowed string) bool {\n    if strings.HasPrefix(id, strings.TrimSuffix(dbPrefix, \"-\")+\"-\") { return true }\n    for _, a := range strings.Split(allowed, \",\") {\n        a = strings.TrimSuffix(strings.TrimSpace(a), \"-\")\n        if a != \"\" && strings.HasPrefix(id, a+\"-\") { return true }\n    }\n    return false\n}\nif !idPrefixAllowed(id, cfg.Prefix, cfg.AllowedPrefixes) { return fmt.Errorf(\"prefix of %q not allowed\", id) }","typeGuard":null,"tryCatchPattern":"if err := validation.ValidateIDPrefixAllowed(id, dbPrefix, allowedPrefixes, false); err != nil {\n    if !forceFlag { return err }\n    _ = validation.ValidateIDPrefixAllowed(id, dbPrefix, allowedPrefixes, true)\n}","preventionTips":["Add every legitimate team prefix to allowed_prefixes","Reject foreign-tracker IDs (gh-123, jira keys) at your tool's input boundary","Verify IDs with `bd show` before referencing cross-repo","Keep --force behind an explicit user flag"],"tags":["prefix","configuration","validation","id","go"],"backgroundTag":"prefix-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}