{"record":{"id":"42843a613399736f","repo":"gastownhall/beads","slug":"swarm-molecule-s-has-no-linked-epic","errorCode":null,"errorMessage":"swarm molecule '%s' has no linked epic","messagePattern":"swarm molecule '(.+?)' has no linked epic","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/swarm_proxied_server.go","lineNumber":144,"sourceCode":"\n\t\tvar epic *types.Issue\n\n\t\tif issue.IssueType == \"molecule\" && issue.MolType == types.MolTypeSwarm {\n\t\t\tdeps, err := r.GetDependencyRecords(ctx, issue.ID)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to get swarm dependencies: %v\", err)\n\t\t\t}\n\t\t\tfor _, dep := range deps {\n\t\t\t\tif dep.Type == types.DepRelatesTo {\n\t\t\t\t\tepic, err = uw.IssueUseCase().GetIssue(ctx, dep.DependsOnID)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"failed to get linked epic: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif epic == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"swarm molecule '%s' has no linked epic\", issueID)\n\t\t\t}\n\t\t} else if issue.IssueType == types.TypeEpic || issue.IssueType == \"molecule\" {\n\t\t\tepic = issue\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"'%s' is not an epic or swarm molecule (type: %s)\", issueID, issue.IssueType)\n\t\t}\n\n\t\tstatus, err := getSwarmStatus(ctx, r, epic)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to get swarm status: %v\", err)\n\t\t}\n\t\treturn status, nil\n\t})\n\tif err != nil {\n\t\treturn HandleErrorRespectJSON(\"%v\", err)\n\t}\n\n\tif jsonOutput {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/swarm_proxied_server.go#L126-L162","documentation":"Thrown when a swarm molecule's dependency records contain no DepRelatesTo edge, so no linked epic could be identified. This is a data-model invariant error: every swarm molecule must relate-to exactly one epic.","triggerScenarios":"Creating a molecule with MolType=MolTypeSwarm but never adding a relates-to dependency to an epic; the relates-to dep was deleted; or the deps loop filtered out all rows because dep.Type never matched types.DepRelatesTo.","commonSituations":"Hand-editing issue JSONL exports and dropping the dependency; older bd versions or scripts that create swarm molecules without linking; a sync conflict that dropped the dependency row.","solutions":["Add the missing link: `bd dep add <molecule-id> <epic-id> --type relates-to`","Verify existing deps with `bd dep list <molecule-id>`","Recreate the molecule under the correct epic instead of repairing the link"],"exampleFix":"// before (molecule created without epic link)\nbd mol create my-swarm --type swarm\n// after\nbd mol create my-swarm --type swarm\nbd dep add bd-123 bd-100 --type relates-to","handlingStrategy":"validation","validationCode":"// check a swarm molecule has a relates-to dep before invoking swarm\nhasEpic := false\nfor _, dep := range deps {\n    if dep.Type == \"relates-to\" { hasEpic = true }\n}\nif !hasEpic {\n    return fmt.Errorf(\"molecule %s has no linked epic; run: bd dep add %s <epic> --type relates-to\", id, id)\n}","typeGuard":"func isSwarmMoleculeLinked(issue *types.Issue, deps []types.Dependency) bool {\n    if issue.IssueType != \"molecule\" || issue.MolType != types.MolTypeSwarm {\n        return false\n    }\n    for _, d := range deps {\n        if d.Type == types.DepRelatesTo { return true }\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always create swarm molecules via `bd mol create` so the epic link is established","Run `bd dep list <molecule>` after any manual JSONL editing","Add a CI check that every MolTypeSwarm molecule has a relates-to dep"],"tags":["go","swarm","data-integrity"],"backgroundTag":"swarm-molecule-unlinked","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}