{"record":{"id":"2e214f87b33869db","repo":"gastownhall/beads","slug":"failed-to-generate-unique-id-for-issue-s-after","errorCode":null,"errorMessage":"failed to generate unique ID for issue '%s' after trying lengths %d-%d with 10 nonces each","messagePattern":"failed to generate unique ID for issue '(.+?)' after trying lengths (.+?)-(.+?) with 10 nonces each","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/linear/mapping.go","lineNumber":119,"sourceCode":"\t\t\t\t\tissue.Title,\n\t\t\t\t\tissue.Description,\n\t\t\t\t\tcreator,\n\t\t\t\t\tissue.CreatedAt,\n\t\t\t\t\tlength,\n\t\t\t\t\tnonce,\n\t\t\t\t)\n\n\t\t\t\tif !usedIDs[candidate] {\n\t\t\t\t\tissue.ID = candidate\n\t\t\t\t\tusedIDs[candidate] = true\n\t\t\t\t\tgenerated = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif !generated {\n\t\t\treturn fmt.Errorf(\"failed to generate unique ID for issue '%s' after trying lengths %d-%d with 10 nonces each\",\n\t\t\t\tissue.Title, baseLength, maxLength)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// MappingConfig holds configurable mappings between Linear and Beads.\n// All maps use lowercase keys for case-insensitive matching.\ntype MappingConfig struct {\n\t// PriorityMap maps Linear priority (0-4) to Beads priority (0-4).\n\t// Key is Linear priority as string, value is Beads priority.\n\tPriorityMap map[string]int\n\n\t// StateMap maps Linear state types/names to Beads statuses.\n\t// Key is lowercase state type or name, value is Beads status string.\n\tStateMap map[string]string\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/linear/mapping.go#L101-L137","documentation":"GenerateIssueIDs exhaustively tries hash-derived candidate IDs (lengths baseLength..maxLength, 10 nonces each) and returns this error when every candidate collides with an already-used ID. With up to 60 candidates per issue this practically means an ID-space exhaustion or a pathological duplicate-input situation, not a random clash.","triggerScenarios":"Calling GenerateIssueIDs on an issue set where every hash candidate for an issue (deterministic function of prefix, title, description, creator, createdAt, length, nonce) is already present in usedIDs.","commonSituations":"Importing the same dataset repeatedly with identical title/description/creator/createdAt so the same candidate set is produced; a very short baseLength with a large existing issue set; a bug freezing issue.CreatedAt (zero timestamps) making all candidates identical across issues.","solutions":["Check that issues have distinct and correct CreatedAt/timestamps (a common cause is all-zero CreatedAt).","Increase baseLength/maxLength to enlarge the candidate ID space.","Ensure existing IDs are recorded correctly in usedIDs and that previously generated IDs are persisted between runs.","Verify you are not re-importing duplicates of the same issue content.","Report upstream if it persists with distinct inputs — 60 collisions in a row indicates a hash or usedIDs bug."],"exampleFix":"// before\nissues := loadIssues() // CreatedAt zero-value for all issues\nerr := linear.GenerateIssueIDs(issues, \"bd-\", 3, 8)\n// after\nfor i := range issues {\n\tif issues[i].CreatedAt.IsZero() {\n\t\tissues[i].CreatedAt = time.Now().UTC() // ensure unique hash input\n\t}\n}\nerr := linear.GenerateIssueIDs(issues, \"bd-\", 3, 8)","handlingStrategy":"validation","validationCode":"func validateIDInputs(issues []Issue) error {\n\tseenCreated := map[string]bool{}\n\tfor _, is := range issues {\n\t\tif is.CreatedAt.IsZero() {\n\t\t\treturn fmt.Errorf(\"issue %q has zero CreatedAt; fix timestamps before ID generation\", is.Title)\n\t\t}\n\t\tkey := is.Title + \"|\" + is.Description + \"|\" + is.CreatedAt.String()\n\t\tif seenCreated[key] {\n\t\t\treturn fmt.Errorf(\"duplicate issue content for %q\", is.Title)\n\t\t}\n\t\tseenCreated[key] = true\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := linear.GenerateIssueIDs(issues, prefix, 3, 8); err != nil {\n\treturn fmt.Errorf(\"ID generation failed (check for duplicate inputs or zero timestamps): %w\", err)\n}","preventionTips":["Ensure CreatedAt is set and unique per issue before generation.","Persist generated IDs so later runs don't re-generate and collide.","Avoid importing the same dataset twice without deduplication.","Use a baseLength that scales with your issue count (larger space for big sets).","Add a unit test with production-scale issue sets to catch exhaustion early."],"tags":["id-generation","hash-collision","linear"],"backgroundTag":"id-generation-exhausted","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}