{"record":{"id":"a15917afd088b997","repo":"gastownhall/beads","slug":"failed-to-commit-federation-peer-w","errorCode":null,"errorMessage":"failed to commit federation peer: %w","messagePattern":"failed to commit federation peer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/credentials.go","lineNumber":316,"sourceCode":"\t\t\tpassword_encrypted = VALUES(password_encrypted),\n\t\t\tsovereignty = VALUES(sovereignty),\n\t\t\tupdated_at = CURRENT_TIMESTAMP\n\t`, peer.Name, peer.RemoteURL, peer.Username, encryptedPwd, peer.Sovereignty)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to add federation peer: %w\", err)\n\t}\n\n\t// Also add the Dolt remote.\n\tif err := s.AddRemote(ctx, peer.Name, peer.RemoteURL); err != nil {\n\t\t// Ignore \"remote already exists\" errors\n\t\tif !strings.Contains(err.Error(), \"already exists\") {\n\t\t\treturn fmt.Errorf(\"failed to add dolt remote: %w\", err)\n\t\t}\n\t}\n\n\tif err := s.doltAddAndCommit(ctx, []string{\"federation_peers\"}, \"federation: add peer \"+peer.Name); err != nil {\n\t\treturn fmt.Errorf(\"failed to commit federation peer: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// GetFederationPeer retrieves a federation peer by name.\n// Returns storage.ErrNotFound (wrapped) if the peer does not exist.\nfunc (s *DoltStore) GetFederationPeer(ctx context.Context, name string) (*storage.FederationPeer, error) {\n\tvar peer storage.FederationPeer\n\tvar encryptedPwd []byte\n\tvar lastSync sql.NullTime\n\tvar username sql.NullString\n\n\terr := s.db.QueryRowContext(ctx, `\n\t\tSELECT name, remote_url, username, password_encrypted, sovereignty, last_sync, created_at, updated_at\n\t\tFROM federation_peers WHERE name = ?\n\t`, name).Scan(&peer.Name, &peer.RemoteURL, &username, &encryptedPwd, &peer.Sovereignty, &lastSync, &peer.CreatedAt, &peer.UpdatedAt)\n","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/credentials.go#L298-L334","documentation":"After the upsert and remote registration, addFederationPeer commits the federation_peers table change to Dolt history via doltAddAndCommit. This wraps failure of that staging/commit step, meaning the credentials row may be visible in the working set but not committed, breaking Dolt-versioned consistency.","triggerScenarios":"doltAddAndCommit fails: `dolt add federation_peers` or `dolt commit` subprocess error — no Dolt identity configured (user.name/user.email), merge conflict or dirty working set, CLI database missing in server mode, or the commit fails due to lock contention.","commonSituations":"Fresh environment where git/dolt committer identity is unset; concurrent bd processes committing simultaneously; the CLI-side database directory absent or corrupted in server-mode setups.","solutions":["Check the wrapped inner error from doltAddAndCommit for the concrete dolt CLI message.","Configure committer identity (dolt config --global user.name/user.email) if the error mentions missing identity.","Retry after resolving any dirty/conflicting working set; avoid running concurrent writes from multiple bd processes on the same workspace.","Verify the CLI database directory exists and is healthy in server-mode deployments; re-run AddFederationPeer (idempotent upsert) once fixed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := store.AddFederationPeer(ctx, peer); err != nil && strings.Contains(err.Error(), \"failed to commit federation peer\") {\n    // configure dolt identity or resolve dirty working set, then retry\n    err = store.AddFederationPeer(ctx, peer)\n}","preventionTips":["Set dolt/git user.name and user.email globally in CI images","Avoid concurrent bd writers on the same workspace","Ensure the CLI database directory exists in server-mode setups"],"tags":["go","dolt","commit","federation"],"backgroundTag":"dolt-commit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}