{"record":{"id":"7382f5df581cd054","repo":"gastownhall/beads","slug":"get-dependency-counts-probe-w","errorCode":null,"errorMessage":"get dependency counts: probe: %w","messagePattern":"get dependency counts: probe: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/dependency_queries.go","lineNumber":442,"sourceCode":"\tif err := tx.QueryRowContext(ctx, query, args...).Scan(&n); err != nil {\n\t\treturn 0, fmt.Errorf(\"count dependent records from %s: %w\", depTable, err)\n\t}\n\treturn n, nil\n}\n\nfunc GetDependencyCountsInTx(ctx context.Context, tx DBTX, issueIDs []string) (map[string]*types.DependencyCounts, error) {\n\tif len(issueIDs) == 0 {\n\t\treturn make(map[string]*types.DependencyCounts), nil\n\t}\n\n\tresult := make(map[string]*types.DependencyCounts)\n\tfor _, id := range issueIDs {\n\t\tresult[id] = &types.DependencyCounts{}\n\t}\n\n\tdepTables := []string{\"dependencies\", \"wisp_dependencies\"}\n\tif empty, probeErr := wispsTableEmptyOrMissingInTx(ctx, tx); probeErr != nil {\n\t\treturn nil, fmt.Errorf(\"get dependency counts: probe: %w\", probeErr)\n\t} else if empty {\n\t\tdepTables = []string{\"dependencies\"}\n\t}\n\n\tfor start := 0; start < len(issueIDs); start += queryBatchSize {\n\t\tend := start + queryBatchSize\n\t\tif end > len(issueIDs) {\n\t\t\tend = len(issueIDs)\n\t\t}\n\t\tbatch := issueIDs[start:end]\n\n\t\tplaceholders := make([]string, len(batch))\n\t\targs := make([]any, len(batch))\n\t\tfor i, id := range batch {\n\t\t\tplaceholders[i] = \"?\"\n\t\t\targs[i] = id\n\t\t}\n\t\tinClause := strings.Join(placeholders, \",\")","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/dependency_queries.go#L424-L460","documentation":"This error wraps a failure of wispsTableEmptyOrMissingInTx, the probe that decides whether GetDependencyCountsInTx needs to scan wisp_dependencies at all. If the probe query itself fails (as opposed to reporting the table is empty/missing), counts cannot proceed and this error is returned.","triggerScenarios":"Calling GetDependencyCountsInTx (e.g. via HydrateReadyRowInTx) when the wisps-table probe query fails: the probe's underlying table is inaccessible in an unexpected way, the context is canceled, the connection drops, or the driver returns an error the probe doesn't classify as 'missing/empty'.","commonSituations":"Permission errors on the wisps table that the missing-table detection misreads; connection instability during hydration; context deadline exceeded while hydrating many rows; corrupt storage preventing the probe's metadata read.","solutions":["Inspect the wrapped probe error to see the underlying cause.","If it's a permission or detection issue, ensure the probe's isTableNotExistError/empty classification matches your driver's behavior.","Run migrations/repair so the wisps and wisp_dependencies tables are in an expected state.","Retry on transient connection or deadline errors; extend the context deadline for large hydrations.","Verify DB grants cover all wisps-related tables."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate the wisps probe environment: table state is classifiable\nvar one int\nif err := tx.QueryRowContext(ctx, \"SELECT 1 FROM wisps LIMIT 1\").Scan(&one); err != nil && !isTableNotExistError(err) {\n    return fmt.Errorf(\"wisps probe will fail during hydration: %w\", err)\n}","typeGuard":"func wispsProbeWillSucceed(ctx context.Context, tx DBTX) bool {\n    _, err := wispsTableEmptyOrMissingInTx(ctx, tx)\n    return err == nil\n}","tryCatchPattern":"counts, err := GetDependencyCountsInTx(ctx, tx, issueIDs)\nif err != nil && strings.Contains(err.Error(), \"probe: \") {\n    // classify underlying cause: permissions vs connection vs schema; fix environment, not retry blindly\n}","preventionTips":["Ensure DB grants cover wisps-related tables, not just dependencies","Keep driver error-classification helpers updated for your driver's strings","Set hydration context deadlines proportional to row count","Run migrations so the wisps table is either present-and-valid or cleanly absent"],"tags":["database","sql","hydration","storage","wisp-tables"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}