{"record":{"id":"1cd8d67dfad2098e","repo":"gastownhall/beads","slug":"query-dependents-from-s-w","errorCode":null,"errorMessage":"query dependents from %s: %w","messagePattern":"query dependents from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/delete_role.go","lineNumber":207,"sourceCode":"\t}\n\tbySource := make(map[string]map[string]bool)\n\tfor i := 0; i < len(ids); i += deleteBatchSize {\n\t\tend := i + deleteBatchSize\n\t\tif end > len(ids) {\n\t\t\tend = len(ids)\n\t\t}\n\t\tinClause, args := buildSQLInClause(ids[i:end])\n\n\t\tfor _, depTable := range []string{\"dependencies\", \"wisp_dependencies\"} {\n\t\t\trows, err := tx.QueryContext(ctx,\n\t\t\t\tfmt.Sprintf(`SELECT %s AS depends_on_id, issue_id FROM %s WHERE %s`,\n\t\t\t\t\tDepTargetExpr, depTable, depTargetIn(\"\", inClause)),\n\t\t\t\targs...)\n\t\t\tif err != nil {\n\t\t\t\tif optionalBlockedTable(depTable) && isTableNotExistError(err) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn nil, fmt.Errorf(\"query dependents from %s: %w\", depTable, err)\n\t\t\t}\n\t\t\tfor rows.Next() {\n\t\t\t\tvar target, dependent string\n\t\t\t\tif err := rows.Scan(&target, &dependent); err != nil {\n\t\t\t\t\t_ = rows.Close()\n\t\t\t\t\treturn nil, fmt.Errorf(\"scan dependent: %w\", err)\n\t\t\t\t}\n\t\t\t\tif idSet[dependent] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif bySource[target] == nil {\n\t\t\t\t\tbySource[target] = make(map[string]bool)\n\t\t\t\t}\n\t\t\t\tbySource[target][dependent] = true\n\t\t\t}\n\t\t\t_ = rows.Close()\n\t\t\tif err := rows.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"iterate dependents from %s: %w\", depTable, err)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/delete_role.go#L189-L225","documentation":"ExternalDependentsBySourceInTx queries each dependency plane ('dependencies', 'wisp_dependencies') in batches for rows depending on the given ids. This error wraps a query-execution failure and names the offending table. A missing optional table is deliberately skipped via optionalBlockedTable + isTableNotExistError, so reaching this error means a real failure, not an absent plane.","triggerScenarios":"tx.QueryContext on 'dependencies' or 'wisp_dependencies' returns an error that is not a tolerated 'table not exist' — connection failure, SQL/driver error, or cancelled context inside the batched IN query.","commonSituations":"DB connection dropped mid-delete; context cancellation; driver incompatibility producing unexpected SQL errors; a genuinely absent optional table whose error text is not recognized by isTableNotExistError on your driver version.","solutions":["Read the wrapped driver error and the named table in the message","If the table should be optional, check whether isTableNotExistError recognizes your driver's error (driver/version mismatch)","Restore connectivity or the transaction and retry","Update the storage driver/backend to a compatible version","Retry the operation; the query is read-only and safe to re-run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm both planes exist before deleting on your backend\nfor _, t := range []string{\"dependencies\", \"wisp_dependencies\"} {\n    if err := store.PingTable(ctx, t); err != nil { return fmt.Errorf(\"missing table %s\", t) }\n}","typeGuard":"if strings.Contains(err.Error(), \"query dependents from \") {\n    table := extractTable(err) // which plane failed\n    _ = table\n}","tryCatchPattern":"_, err := store.Delete(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"query dependents from\") {\n    log.Printf(\"dependents query failed: %v\", errors.Unwrap(err))\n}","preventionTips":["Run migrations before delete operations","Check driver error-text compatibility for optional-table skipping","Use read-only probes of the dependency tables in health checks","Keep contexts alive for the whole delete"],"tags":["database","sql","dependents","query-error"],"backgroundTag":"db-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}