fix(create): warn, not fail, when a routed create's follow-up commit fails
The follow-up Dolt commit a routed create runs in the target store only commits under dolt.auto-commit=on: maybeAutoCommitStore returns early in every other mode. In that mode issueOpsContext does not defer the version commit, so ops.Create has already committed the new issue before the flush runs, and a failure of that commit makes ops.Create return an error, so the create exits 1 before it reaches the flush. A failed flush therefore cannot leave the issue in the working set only. Failing the command at that point reports a durable create as an error, replaces the --json result with an error object, and skips the push to a remote target. Keep the fix for the swallowed error, but report it the way create's other follow-up commit does: a stderr warning that names the issue, the target repo and the error, and the create still succeeds. The flush moves into flushRoutedCreate, so a unit test pins the warning with an injected commit failure. The cross-repo embedded tests now assert that the created issues are in the target's HEAD commit and that its working set is clean. A routed bare create (no --parent, --deps or --waits-for) also ran the bare create's follow-up commit. setStore has made the target the command's store by then, so both commits ran on the same store, and one persistent commit failure printed two warnings, the first naming neither the issue nor the target. The bare create's commit now skips routed creates, so flushRoutedCreate is a routed create's only follow-up commit. The two gates differ only when dolt.auto-commit is unset. writesCommitNow treats an unset mode as on, so there too ops.Create has already committed the issue. Corrections to the message of "fix(create): report a failed commit instead of printing success": - The create does not fail on this error and prints no `bd dolt commit` hint. A failed follow-up commit is the warning described above. - "The row existed only in the Dolt working set" does not hold on this tree, for the reason in the first paragraph. This change therefore does not explain the 2026-09-02 report of three lost creates, and the cause of that loss is not established here. - cmd/bd has 19 production commitPendingIfEmbedded call sites, not 23. Of these, 17 return the error and the `bd create --file` path warns; this routed flush was the only one that discarded it. The counts are the same atc0d8da42de, the original commit's parent, and atb303d494df. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: deacon <mtccressall@gmail.com>
This commit is contained in:
parent
fbd120daa2
commit
312d0dd5a6
4 changed files with 88 additions and 26 deletions
|
|
@ -524,6 +524,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
|
||||
- **A routed `bd create` reports a failed follow-up commit** (#6254). When
|
||||
`--repo` or the `routing.*` settings send a create to another repository,
|
||||
the follow-up Dolt commit in that repository wrote its error only to the
|
||||
debug log. It now prints `Warning: created <id>, but the follow-up Dolt
|
||||
commit in <repo> failed: <error>` on stderr. The create still succeeds,
|
||||
prints the issue and syncs a remote target, because that commit runs only
|
||||
under `dolt.auto-commit=on`, where the create has already committed the new
|
||||
issue.
|
||||
- **`bd gate list` works over a connected HTTP workspace** (S20). The
|
||||
workspace-wide listing built a raw `SearchIssues` filter, which the HTTP
|
||||
backend refuses, so gc's `renudge-stale-human-gates` order failed on every
|
||||
|
|
|
|||
|
|
@ -606,9 +606,11 @@ var createCmd = &cobra.Command{
|
|||
created.Comments = nil
|
||||
|
||||
edges := createDepEdges{parentID: parentID, specs: depSpecs, waitsFor: waitsForSpec}
|
||||
if edges.empty() {
|
||||
routed := repoPath != "." && targetStore != nil
|
||||
if edges.empty() && !routed {
|
||||
// Bare create: preserve the embedded-mode follow-up Dolt commit.
|
||||
// The deps path commits inside its transaction instead.
|
||||
// The deps path commits inside its transaction instead, and a
|
||||
// routed create's one follow-up commit is flushRoutedCreate.
|
||||
shouldCommit, err := shouldCommitCreatePostWrites(created, false)
|
||||
if err != nil {
|
||||
return HandleError("dolt auto-commit failed: %v", err)
|
||||
|
|
@ -621,30 +623,8 @@ var createCmd = &cobra.Command{
|
|||
}
|
||||
}
|
||||
|
||||
if repoPath != "." && targetStore != nil {
|
||||
if err := commitPendingIfEmbedded(ctx, targetStore, currentActor(), doltAutoCommitParams{
|
||||
Command: "create",
|
||||
IssueIDs: []string{created.ID},
|
||||
}); err != nil {
|
||||
// A failed commit here USED TO be swallowed into debug.Logf, after
|
||||
// which this function went on to print "✓ Created issue: <id>" and
|
||||
// return nil. The row exists only in the working set at that point,
|
||||
// so the caller is told the issue was created and is given an ID
|
||||
// that does not survive a working-set reset.
|
||||
//
|
||||
// That is not hypothetical. A Gas Town patrol reported creating
|
||||
// three beads on 2026-09-02 and none of them existed afterwards; a
|
||||
// byte copy of the store taken 6.5 hours later contained none of
|
||||
// the three, while every issue the SAME session UPDATED was present
|
||||
// in that same copy. The split is explained exactly here: of the 23
|
||||
// commitPendingIfEmbedded call sites, 16 return the error and this
|
||||
// was the only one that discarded it.
|
||||
//
|
||||
// Report it the way `bd update` does. The issue may still be
|
||||
// recoverable with `bd dolt commit`, which the caller can only do
|
||||
// if they are told.
|
||||
return HandleErrorRespectJSON("created %s but failed to commit it: %v\nThe issue exists in the working set only — run 'bd dolt commit' to persist it.", created.ID, err)
|
||||
}
|
||||
if routed {
|
||||
flushRoutedCreate(ctx, targetStore, repoPath, created.ID)
|
||||
}
|
||||
|
||||
if remoteCache != nil {
|
||||
|
|
@ -924,6 +904,19 @@ func shouldCommitCreatePostWrites(_ *types.Issue, _ bool) (bool, error) {
|
|||
return embeddedWritesCommitNow()
|
||||
}
|
||||
|
||||
// flushRoutedCreate runs a routed create's follow-up Dolt commit in the target
|
||||
// store. That commit runs only under dolt.auto-commit=on, where ops.Create has
|
||||
// already committed the new row, so its failure cannot lose the issue: it is a
|
||||
// warning that names the target, and the create still succeeds.
|
||||
func flushRoutedCreate(ctx context.Context, target storage.DoltStorage, repoPath, id string) {
|
||||
if err := commitPendingIfEmbedded(ctx, target, currentActor(), doltAutoCommitParams{
|
||||
Command: "create",
|
||||
IssueIDs: []string{id},
|
||||
}); err != nil {
|
||||
WarnError("created %s, but the follow-up Dolt commit in %s failed: %v", id, repoPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
func createDepsAcceptedTypeList() string {
|
||||
names := []string{"blocked-by", "depends-on"}
|
||||
for _, depType := range types.WellKnownDependencyTypes() {
|
||||
|
|
|
|||
|
|
@ -159,6 +159,33 @@ func assertDepExists(t *testing.T, beadsDir, database, issueID, dependsOnID stri
|
|||
}
|
||||
}
|
||||
|
||||
// assertCommittedAtHead verifies via raw SQL that each issue is in the store's
|
||||
// HEAD commit and that its working set holds no uncommitted change.
|
||||
func assertCommittedAtHead(t *testing.T, beadsDir, database string, ids ...string) {
|
||||
t.Helper()
|
||||
db, cleanup, err := embeddeddolt.OpenSQL(t.Context(), filepath.Join(beadsDir, "embeddeddolt"), database, "main")
|
||||
if err != nil {
|
||||
t.Fatalf("OpenSQL: %v", err)
|
||||
}
|
||||
defer cleanup()
|
||||
for _, id := range ids {
|
||||
var count int
|
||||
if err := db.QueryRowContext(t.Context(), "SELECT COUNT(*) FROM issues AS OF 'HEAD' WHERE id = ?", id).Scan(&count); err != nil {
|
||||
t.Fatalf("count %s at HEAD: %v", id, err)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Errorf("issue %s at HEAD: count = %d, want 1", id, count)
|
||||
}
|
||||
}
|
||||
var dirty string
|
||||
if err := db.QueryRowContext(t.Context(), "SELECT COALESCE(GROUP_CONCAT(table_name), '') FROM dolt_status").Scan(&dirty); err != nil {
|
||||
t.Fatalf("query dolt_status: %v", err)
|
||||
}
|
||||
if dirty != "" {
|
||||
t.Errorf("uncommitted tables in the working set: %s", dirty)
|
||||
}
|
||||
}
|
||||
|
||||
func assertDepExistsWithType(t *testing.T, beadsDir, database, issueID, dependsOnID, expectedType string) {
|
||||
t.Helper()
|
||||
dataDir := filepath.Join(beadsDir, "embeddeddolt")
|
||||
|
|
@ -990,6 +1017,7 @@ func TestEmbeddedCreateCrossRepo(t *testing.T) {
|
|||
|
||||
// Verify issue exists in the TARGET store, not the source
|
||||
targetBeadsDir := filepath.Join(targetDir, ".beads")
|
||||
assertCommittedAtHead(t, targetBeadsDir, "tgt", issue.ID)
|
||||
tgtStore := openStore(t, targetBeadsDir, "tgt")
|
||||
got, err := tgtStore.GetIssue(t.Context(), issue.ID)
|
||||
if err != nil {
|
||||
|
|
@ -1044,6 +1072,7 @@ func TestEmbeddedCreateCrossRepoWithParent(t *testing.T) {
|
|||
// Verify parent-child dependency exists in the target store
|
||||
targetBeadsDir := filepath.Join(targetDir, ".beads")
|
||||
assertDepExists(t, targetBeadsDir, "tgt", child.ID, parent.ID)
|
||||
assertCommittedAtHead(t, targetBeadsDir, "tgt", parent.ID, child.ID)
|
||||
}
|
||||
|
||||
func TestEmbeddedCreateDryRunRepoDoesNotInitializeTarget(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,38 @@ func TestCommitPendingIfEmbeddedPropagatesEmbeddedError(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFlushRoutedCreateWarnsOnCommitFailure(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
{name: "commit succeeds", want: ""},
|
||||
{
|
||||
name: "commit fails",
|
||||
err: errors.New("commit failed"),
|
||||
want: "Warning: created tgt-1, but the follow-up Dolt commit in ../planning failed: commit failed\n",
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
saveStorageMode(t)
|
||||
serverMode = false
|
||||
proxiedServerMode = false
|
||||
|
||||
fake := &fakeCommitPendingStore{err: tc.err}
|
||||
got := captureStderr(t, func() {
|
||||
flushRoutedCreate(context.Background(), fake, "../planning", "tgt-1")
|
||||
})
|
||||
if fake.commitCalls != 1 {
|
||||
t.Fatalf("Commit calls = %d, want 1", fake.commitCalls)
|
||||
}
|
||||
if got != tc.want {
|
||||
t.Fatalf("stderr = %q, want %q", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldCommitCreatePostWritesSkipsServerMode(t *testing.T) {
|
||||
saveStorageMode(t)
|
||||
serverMode = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue