{"record":{"id":"3b93418ccb26265f","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-deleteallforids-rows-a","errorCode":null,"errorMessage":"db: DependencySQLRepository.DeleteAllForIDs rows affected: %w","messagePattern":"db: DependencySQLRepository\\.DeleteAllForIDs rows affected: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":777,"sourceCode":"\t\tph := strings.Join(placeholders, \",\")\n\t\t// Journal the edges this batch is about to remove, while they and their\n\t\t// source snapshots are still readable.\n\t\tif err := issueops.RecordDependencyRemovalsForTableInTx(ctx, r.runner, table, batch); err != nil {\n\t\t\treturn total, fmt.Errorf(\"db: DependencySQLRepository.DeleteAllForIDs journal removals from %s: %w\", table, err)\n\t\t}\n\t\t//nolint:gosec // G201: table is one of two hardcoded constants; ? placeholders only.\n\t\tres, err := r.runner.ExecContext(ctx,\n\t\t\tfmt.Sprintf(\"DELETE FROM %s WHERE issue_id IN (%s) OR %s IN (%s)\", table, ph, issueops.DepTargetExpr, ph),\n\t\t\targs...)\n\t\tif err != nil {\n\t\t\tif opts.UseWispsTable && dberrors.IsTableNotExist(err) {\n\t\t\t\treturn total, nil\n\t\t\t}\n\t\t\treturn total, fmt.Errorf(\"db: DependencySQLRepository.DeleteAllForIDs from %s: %w\", table, err)\n\t\t}\n\t\tn, err := res.RowsAffected()\n\t\tif err != nil {\n\t\t\treturn total, fmt.Errorf(\"db: DependencySQLRepository.DeleteAllForIDs rows affected: %w\", err)\n\t\t}\n\t\ttotal += int(n)\n\t}\n\treturn total, nil\n}\n\nfunc (r *dependencySQLRepositoryImpl) CountAllForIDs(ctx context.Context, ids []string, opts domain.DepCountsOpts) (int, error) {\n\tif len(ids) == 0 {\n\t\treturn 0, nil\n\t}\n\ttable := \"dependencies\"\n\tif opts.UseWispsTable {\n\t\ttable = \"wisp_dependencies\"\n\t}\n\ttotal := 0\n\tfor start := 0; start < len(ids); start += deleteBatchSize {\n\t\tend := start + deleteBatchSize\n\t\tif end > len(ids) {","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L759-L795","documentation":"DeleteAllForIDs batches a DELETE across dependency tables, then calls res.RowsAffected() to tally how many rows each batch removed. This error wraps a failure of RowsAffected() itself — the DELETE statement succeeded, but the driver could not report the row count. It is a driver/database-metadata failure, not a SQL failure, so the deletes may have already been applied.","triggerScenarios":"Calling DependencySQLRepository.DeleteAllForIDs(ctx, ids, opts) where the underlying driver's ExecContext result cannot compute RowsAffected — e.g. a driver whose result type does not implement RowsAffected, or a driver error surfaced only when reading the affected-row count.","commonSituations":"Running against a non-Dolt/unsupported driver substituted behind the storage driver interface; driver version changes that alter result metadata handling; a closed or broken connection between ExecContext returning and RowsAffected being read.","solutions":["Check the configured storage driver implements database/sql RowsAffected correctly; use the supported dolthub/driver-based driver.","Upgrade/verify the database driver version for known RowsAffected bugs.","Retry the operation — the deletes may have partially applied; verify counts with CountAllForIDs afterward.","If writing a custom driver via the driver interface, return a result that implements RowsAffected."],"exampleFix":"// before: custom driver returns sql.Result without RowsAffected support\n// after: implement RowsAffected on your driver result\ntype result struct{ rows int64 }\nfunc (r result) RowsAffected() (int64, error) { return r.rows, nil }\nfunc (r result) LastInsertId() (int64, error) { return 0, nil }","handlingStrategy":"retry","validationCode":"// verify driver supports RowsAffected before bulk delete\nvar probe any = driverResult // your driver result\nif _, ok := probe.(interface{ RowsAffected() (int64, error) }); !ok {\n    return errors.New(\"driver result does not implement RowsAffected\")\n}","typeGuard":"func supportsRowsAffected(r driver.Result) bool {\n\t_, err := r.RowsAffected()\n\treturn err == nil\n}","tryCatchPattern":"n, err := repo.DeleteAllForIDs(ctx, ids, opts)\nvar re *retryableError\nif errors.As(err, &re) || isTransient(err) {\n    // retry with backoff; deletes may have partially applied\n    verified, _ := repo.CountAllForIDs(ctx, ids, opts)\n    _ = verified\n}","preventionTips":["Always use the supported dolthub/driver-based storage driver.","Keep the database driver updated for known RowsAffected bugs.","After a failed delete tally, re-count rows to verify actual state before retrying."],"tags":["database","driver","rows-affected","delete"],"backgroundTag":"rows-affected-unsupported","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}