{"record":{"id":"24f1302eb96c707a","repo":"gastownhall/beads","slug":"check-staged-changes-before-commit-w-24f130","errorCode":null,"errorMessage":"check staged changes before commit: %w","messagePattern":"check staged changes before commit: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":3311,"sourceCode":"\t\tdefer conn.Close()\n\n\t\tfor _, table := range tables {\n\t\t\tif err := schema.DrainCall(ctx, conn, \"CALL DOLT_ADD(?)\", table); err != nil {\n\t\t\t\treturn s.recordDoltPublicationFailure(ctx,\n\t\t\t\t\tfmt.Errorf(\"dolt add %s after SQL mutation: %w: %w\", table, err, ErrCommitIndeterminate))\n\t\t\t}\n\t\t}\n\n\t\t// Skip the commit when nothing was actually staged (idempotent no-op\n\t\t// write), so Dolt does not log a server-side \"nothing to commit\" warning\n\t\t// on every reconcile-cadence call. The guard tests the STAGED set rather\n\t\t// than the whole working set because this helper stages only a fixed\n\t\t// table list — an unrelated dirty table must not trigger an empty '-m'\n\t\t// commit. A guard-read failure is NOT a publication failure: nothing has\n\t\t// been committed and nothing is indeterminate, so plain error return.\n\t\tstaged, err := issueops.HasStagedChanges(ctx, conn)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"check staged changes before commit: %w\", err)\n\t\t}\n\t\tif !staged {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := schema.DrainCall(ctx, conn, \"CALL DOLT_COMMIT('-m', ?, '--author', ?)\",\n\t\t\tcommitMsg, s.commitAuthorString()); err != nil && !isDoltNothingToCommit(err) {\n\t\t\treturn s.recordDoltPublicationFailure(ctx,\n\t\t\t\tfmt.Errorf(\"dolt commit after SQL mutation: %w: %w\", err, ErrCommitIndeterminate))\n\t\t}\n\t\treturn nil\n\t})\n}\n\nfunc (s *DoltStore) wrapDoltPublicationFailure(ctx context.Context, op string, err error) error {\n\treturn s.recordDoltPublicationFailure(ctx, wrapSQLCommitError(op, err))\n}\n","sourceCodeStart":3293,"sourceCodeEnd":3329,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L3293-L3329","documentation":"The pre-commit guard HasStagedChanges failed, so the store cannot tell whether anything is staged and aborts with a plain error (deliberately NOT marked as a publication failure, since nothing was committed yet).","triggerScenarios":"doltAddAndCommit runs its staged-changes guard query and the query errors — connection drop, permission issue, or failure reading dolt_status internally.","commonSituations":"Transient Dolt server error during reconcile-cadence commits; database permission problems; schema change to dolt_status internals.","solutions":["Retry the operation; nothing was committed so a retry is safe.","Verify server connectivity (bd dolt status).","Inspect the wrapped cause (%w) for the specific query error and address it (permissions, schema)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// safe to retry: nothing was committed; confirm DB is queryable first\nif err := s.db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"check staged changes before commit\") {\n    // plain failure, no indeterminacy: safe to retry the operation\n}","preventionTips":["Ensure the database user has permission to read dolt_status.","Retry transient read failures automatically with backoff.","Keep bd version aligned with the database schema.","Monitor server health during reconcile-cadence commits."],"tags":["dolt","staging","guard","database"],"backgroundTag":"dolt-status-check-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}