{"record":{"id":"0d369300df552374","repo":"gastownhall/beads","slug":"check-staged-changes-before-commit-w-0d3693","errorCode":null,"errorMessage":"check staged changes before commit: %w","messagePattern":"check staged changes before commit: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/commit.go","lineNumber":88,"sourceCode":"\tif !pending {\n\t\treturn nil\n\t}\n\n\tfor table := range dirtyTables {\n\t\tif _, err := conn.ExecContext(ctx, \"CALL DOLT_ADD(?)\", table); err != nil {\n\t\t\treturn fmt.Errorf(\"dolt add %s: %w\", table, err)\n\t\t}\n\t}\n\n\t// Precise guard: HasPendingChanges above is global, but we only DOLT_ADD the\n\t// dirty-tracked tables. When those specific tables turn out clean (idempotent\n\t// no-op) while some UNRELATED table is concurrently dirty, the fast-path does\n\t// not fire yet staging stages nothing — so DOLT_COMMIT('-m') would still emit\n\t// the \"nothing to commit\" warning. Check the STAGED set (exactly what '-m'\n\t// will commit) and skip the empty commit.\n\tstaged, err := issueops.HasStagedChanges(ctx, conn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"check staged changes before commit: %w\", err)\n\t}\n\tif !staged {\n\t\treturn nil\n\t}\n\tif author == \"\" {\n\t\t_, err = conn.ExecContext(ctx, \"CALL DOLT_COMMIT('-m', ?)\", commitMsg)\n\t} else {\n\t\t_, err = conn.ExecContext(ctx, \"CALL DOLT_COMMIT('-m', ?, '--author', ?)\", commitMsg, author)\n\t}\n\tif err != nil && !issueops.IsNothingToCommitError(err) {\n\t\treturn fmt.Errorf(\"dolt commit: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":70,"sourceCodeEnd":104,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/commit.go#L70-L104","documentation":"After staging, StageAndCommit calls issueops.HasStagedChanges so DOLT_COMMIT('-m') isn't run against an empty staged set (which would emit a 'nothing to commit' warning); failures in that check are wrapped as 'check staged changes before commit: %w'. Like the pending-changes check, this is a query failure (connection/server issue), not a data problem.","triggerScenarios":"Calling StageAndCommit when the HasStagedChanges query fails — connection loss, Dolt server down, or dolt_status staging query unavailable/changed.","commonSituations":"Long-running process whose connection went stale; embedded Dolt process crash between DOLT_ADD and the staged check; Dolt version where the staged-changes query behaves differently.","solutions":["Reconnect and retry StageAndCommit (the operation is idempotent)","Inspect the wrapped driver error to distinguish connection failure from query/schema failure","Confirm the Dolt version supports the staging queries used by HasStagedChanges"],"exampleFix":"// before\nerr := versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)\n// after\nerr := versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)\nif err != nil && isConnectionError(err) {\n    db = reconnect(ctx)\n    err = versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)\n}","handlingStrategy":"retry","validationCode":"if err := conn.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"connection unhealthy before staged check: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := versioncontrolops.StageAndCommit(ctx, conn, tables, msg, author)\nif err != nil && strings.Contains(err.Error(), \"check staged changes before commit\") {\n    conn = reconnect(ctx)\n    err = versioncontrolops.StageAndCommit(ctx, conn, tables, msg, author)\n}","preventionTips":["Health-check the connection mid-flow if operations are long-running","Retry on transient errors; the staged check makes the commit safe to re-run","Pin a known-good Dolt version in deployments","Run commit flows on a dedicated session to avoid contention"],"tags":["dolt","sql","commit","staging"],"backgroundTag":"dolt-status-check-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}