{"record":{"id":"be75327d1250b1b9","repo":"gastownhall/beads","slug":"db-s-w","errorCode":null,"errorMessage":"db: %s: %w","messagePattern":"db: (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dolt.go","lineNumber":88,"sourceCode":"\nfunc (i *doltVersionControlSQLRepository) Pull(ctx context.Context, args ...string) error {\n\treturn i.call(ctx, \"DOLT_PULL\", args...)\n}\n\nfunc (i *doltVersionControlSQLRepository) Clone(ctx context.Context, args ...string) error {\n\treturn i.call(ctx, \"DOLT_CLONE\", args...)\n}\n\nfunc (i *doltVersionControlSQLRepository) call(ctx context.Context, proc string, args ...string) error {\n\tplaceholders := make([]string, len(args))\n\tiargs := make([]any, len(args))\n\tfor j, a := range args {\n\t\tplaceholders[j] = \"?\"\n\t\tiargs[j] = a\n\t}\n\tquery := \"CALL \" + proc + \"(\" + strings.Join(placeholders, \", \") + \")\"\n\tif _, err := i.runner.ExecContext(ctx, query, iargs...); err != nil {\n\t\treturn fmt.Errorf(\"db: %s: %w\", proc, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":70,"sourceCodeEnd":92,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dolt.go#L70-L92","documentation":"Generic wrapper for failures executing a Dolt stored procedure via CALL. The %s is the procedure name (e.g. dolt_checkout, dolt_add, dolt_commit, dolt_merge), and the wrapped error is the raw SQL driver error. This centralizes all stored-procedure invocation errors from the dolt.go helper.","triggerScenarios":"Calling Checkout, Branch, Add, Commit, Merge, or Remote when the CALL statement fails: unknown procedure (older Dolt server version), wrong argument types/counts, procedure internal failure (merge conflict, checkout with dirty working set, branch already exists), or connection loss.","commonSituations":"Dolt server version mismatch where a newer beads expects a procedure the server doesn't have; dolt_merge failing on conflicts; dolt_branch on an existing branch name; dolt_checkout failing due to uncommitted changes.","solutions":["Read the wrapped driver error: it names the procedure and its internal failure reason","Upgrade the Dolt server to match the version beads expects (missing-procedure errors indicate version skew)","Check preconditions before the call (branch exists, clean working set for checkout/merge)","Retry on transient connection errors; recreate the session if the pool went stale"],"exampleFix":"// before\nif err := conn.Branch(ctx, \"feature\"); err != nil { log.Fatal(err) }\n// after\nif err := conn.Branch(ctx, \"feature\"); err != nil {\n    if strings.Contains(err.Error(), \"already exists\") { /* handle */ }\n    log.Fatalf(\"branch op failed: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// verify server supports the procedure before calling\nvar one int\nif err := db.QueryRow(\"SELECT 1 FROM information_schema.routines WHERE routine_name = 'dolt_merge'\").Scan(&one); err != nil {\n    return fmt.Errorf(\"dolt_merge unavailable on this server version\")\n}","typeGuard":"func isProcMissingErr(err error) bool {\n    return strings.Contains(err.Error(), \"does not exist\") || strings.Contains(err.Error(), \"unknown procedure\")\n}","tryCatchPattern":"if err := conn.Commit(ctx, msg); err != nil {\n    if isProcMissingErr(err) { return upgradeDoltServer() }\n    if strings.Contains(err.Error(), \"conflict\") { return handleMergeConflict() }\n    return fmt.Errorf(\"dolt commit failed: %w\", err)\n}","preventionTips":["Pin and verify the Dolt server version matches beads' expectations","Check for clean working set before checkout/merge calls","Uniquify branch names before dolt_branch","Retry transient connection errors with backoff"],"tags":["database","dolt","stored-procedure","git-like"],"backgroundTag":"dolt-procedure-call-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}