{"record":{"id":"f4f26547c17e74e6","repo":"gastownhall/beads","slug":"dependency-s-s-has-invalid-type","errorCode":null,"errorMessage":"dependency %s -> %s has invalid type","messagePattern":"dependency (.+?) -> (.+?) has invalid type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/migration/legacysqlite/reader.go","lineNumber":926,"sourceCode":"\t\treturn fmt.Errorf(\"dependency %s -> %s crosses ephemeral storage\", id, to)\n\t}\n\tkey := id + \"\\x00\" + to\n\tif seenDeps[key] {\n\t\treturn fmt.Errorf(\"multiple legacy dependencies for %s -> %s\", id, to)\n\t}\n\tseenDeps[key] = true\n\tcreated, e := parseTime(at)\n\tif e != nil {\n\t\treturn e\n\t}\n\tif created.IsZero() {\n\t\treturn fmt.Errorf(\"dependency created_at is zero for %s -> %s\", id, to)\n\t}\n\tif (metadata.Valid && metadata.String != \"\") || (thread.Valid && thread.String != \"\") {\n\t\treturn fmt.Errorf(\"dependency %s -> %s uses unsupported metadata or thread ID\", id, to)\n\t}\n\tif !types.DependencyType(typ).IsValid() {\n\t\treturn fmt.Errorf(\"dependency %s -> %s has invalid type\", id, to)\n\t}\n\td := &types.Dependency{IssueID: id, DependsOnID: to, Type: types.DependencyType(typ), CreatedAt: created, CreatedBy: by, Metadata: nullString(metadata), ThreadID: nullString(thread)}\n\tissue.Dependencies = append(issue.Dependencies, d)\n\treturn nil\n}\n\nfunc loadComments(ctx context.Context, db *sql.Tx, byID map[string]*types.Issue) error {\n\tcomments, err := db.QueryContext(ctx, \"SELECT id,issue_id,author,text,CAST(created_at AS TEXT) FROM comments ORDER BY issue_id,created_at,id\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer comments.Close()\n\ttype commentIdentity struct {\n\t\tissueID, author, text string\n\t\tcreatedAt             time.Time\n\t}\n\tseenComments := make(map[commentIdentity]int64)\n\tfor comments.Next() {","sourceCodeStart":908,"sourceCodeEnd":944,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/migration/legacysqlite/reader.go#L908-L944","documentation":"The legacy row's type column does not map to a valid types.DependencyType, so the importer cannot construct a Dependency and aborts. Dependency types are a closed enum (e.g. blocks, parent-child, conditional-blocks) validated by DependencyType.IsValid().","triggerScenarios":"Legacy SQLite dependency rows whose type value is not one of the recognized dependency type strings/ints — e.g. from an even older schema, corrupted data, or hand-edited SQL.","commonSituations":"Restored or partially-migrated legacy databases; rows inserted by tooling that used free-form type strings; version mismatch where legacy type names were later renamed.","solutions":["Inspect offending rows: SELECT * FROM dependencies WHERE type NOT IN (<valid types>) and fix them to a valid type","Update unknown types to their modern equivalents (e.g. legacy 'related' -> appropriate valid type) in the legacy DB","Remove rows with unrecoverable type values and recreate the dependencies in bd after migration"],"exampleFix":"-- before\n-- type = 'watch'\nUPDATE dependencies SET type = 'blocks' WHERE type = 'watch';\n-- after: type is a valid DependencyType","handlingStrategy":"validation","validationCode":"const VALID = new Set(['blocks','conditional-blocks','parent-child','related']);\nfor (const d of legacyDeps) {\n  if (!VALID.has(String(d.type)))\n    throw new Error(`invalid dependency type '${d.type}' on ${d.issue_id} -> ${d.depends_on_id}`);\n}","typeGuard":"function hasValidType(d, validTypes) {\n  return validTypes.some(t => String(d.type) === t);\n}","tryCatchPattern":"try { migrateLegacySQLite(dbPath) } catch (e) {\n  if (e.message.includes('has invalid type')) {\n    fixUnknownDepTypes(dbPath); // map legacy names -> valid types\n    retry();\n  } else throw e;\n}","preventionTips":["Verify dependency type values against the current DependencyType enum before import","Add a CHECK constraint on the legacy type column","Audit type values with GROUP BY type before migrating"],"tags":["migration","sqlite","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}