{"record":{"id":"2a57e62bf253325e","repo":"gastownhall/beads","slug":"prefix-validation-failed-for-s-w","errorCode":null,"errorMessage":"prefix validation failed for %s: %w","messagePattern":"prefix validation failed for (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/create.go","lineNumber":230,"sourceCode":"\t\tissueTable, _ := TableRouting(issue)\n\t\tprefix := bc.ConfigPrefix\n\t\tif issue.PrefixOverride != \"\" {\n\t\t\tprefix = issue.PrefixOverride\n\t\t} else if issue.IDPrefix != \"\" {\n\t\t\tprefix = bc.ConfigPrefix + \"-\" + issue.IDPrefix\n\t\t} else if IsWisp(issue) {\n\t\t\tprefix = bc.ConfigPrefix + \"-wisp\"\n\t\t}\n\t\tvar err error\n\t\tissue.ID, err = GenerateIssueIDInTable(ctx, tx, issueTable, prefix, issue, actor)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to generate issue ID: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\tif !bc.Opts.SkipPrefixValidation {\n\t\tif err := ValidateIssueIDPrefix(issue.ID, bc.ConfigPrefix, bc.AllowedPrefixes); err != nil {\n\t\t\treturn fmt.Errorf(\"prefix validation failed for %s: %w\", issue.ID, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// CreateIssuesResult reports side effects that callers need for selective\n// Dolt staging after CreateIssuesInTxWithResult returns.\ntype CreateIssuesResult struct {\n\tChangedTables             map[string]bool\n\tChangedChildCounterTables map[string]bool\n}\n\nfunc (r *CreateIssuesResult) markChanged(table string) {\n\tif table == \"\" {\n\t\treturn\n\t}\n\tif r.ChangedTables == nil {\n\t\tr.ChangedTables = map[string]bool{}","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/create.go#L212-L248","documentation":"assignCreateIssueIDInTx validates a newly generated issue ID against the configured prefix rules via ValidateIssueIDPrefix, refusing IDs whose prefix is not in AllowedPrefixes (or not matching ConfigPrefix). Callers can bypass this with Opts.SkipPrefixValidation. The error is wrapped as \"prefix validation failed for %s: %w\" naming the rejected ID.","triggerScenarios":"Creating an issue whose generated ID prefix (e.g. from a custom --prefix or imported ID) is not in the configured allowed prefixes; changing prefix config after issues were created with the old prefix; importing issues from another repo with foreign prefixes without SkipPrefixValidation.","commonSituations":"Teams renaming their issue prefix in config but having automation still creating issues under the old prefix; federated setups importing beads from multiple remotes with different prefixes; misconfigured .beads/beads.jsonp/config prefix setting.","solutions":["Align the ID generation/config: set ConfigPrefix/AllowedPrefixes to include the prefix the ID actually uses.","Set Opts.SkipPrefixValidation = true only if you deliberately accept foreign-prefix IDs (e.g. imports).","Regenerate the ID with the correct prefix before insert."],"exampleFix":"// before\nbc := CreateIssueContext{ConfigPrefix: \"bd\", AllowedPrefixes: []string{\"bd\"}}\n// ID \"jira-123\" -> prefix validation failed\n\n// after\nbc := CreateIssueContext{\n\tConfigPrefix: \"bd\",\n\tAllowedPrefixes: []string{\"bd\", \"jira\"}, // accept imported prefixes\n}","handlingStrategy":"validation","validationCode":"if !slices.Contains(allowedPrefixes, prefixOf(issueID)) {\n\treturn fmt.Errorf(\"prefix %q not allowed (allowed: %v)\", prefixOf(issueID), allowedPrefixes)\n}","typeGuard":null,"tryCatchPattern":"if err := store.CreateIssue(ctx, issue); err != nil {\n\tif strings.HasPrefix(err.Error(), \"prefix validation failed\") {\n\t\treturn fmt.Errorf(\"config/id prefix mismatch; fix prefix config or set SkipPrefixValidation: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Keep ConfigPrefix/AllowedPrefixes in sync whenever the team renames its issue prefix.","Use SkipPrefixValidation only for deliberate imports of foreign-prefix IDs.","Test ID generation against the current prefix config in CI for automation that creates issues."],"tags":["validation","ids","config"],"backgroundTag":"invalid-id-prefix","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}