{"record":{"id":"01e1d508c38c343b","repo":"gastownhall/beads","slug":"resolving-s-w-01e1d5","errorCode":null,"errorMessage":"resolving %s: %w","messagePattern":"resolving (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/heartbeat_proxied_server.go","lineNumber":40,"sourceCode":"// bd-lrgn1): the transaction commits via uow.RunTxEphemeral's SQL-only form,\n// so a heartbeat mints exactly ZERO Dolt commits per invocation — the same\n// commit discipline as the classic DoltStore.HeartbeatIssue, and deliberately\n// nothing here sets commandDidWrite or creates a Dolt commit. The exit code\n// is the worker contract (workers call this every ~90s and only check rc):\n// 0 = lease refreshed; nonzero = the lease is gone (wrong owner, not\n// in_progress, closed, reclaimed) and the worker should stop.\nfunc runHeartbeatProxiedServer(ctx context.Context, id string) error {\n\tif uowProvider == nil {\n\t\treturn HandleErrorRespectJSON(\"proxied-server UOW provider not initialized\")\n\t}\n\n\tres, err := uow.RunTxEphemeral(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (heartbeatProxiedOutcome, error) {\n\t\tissue, _, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)\n\t\tif errors.Is(rerr, storage.ErrNotFound) {\n\t\t\treturn heartbeatProxiedOutcome{}, fmt.Errorf(\"issue %s not found\", id)\n\t\t}\n\t\tif rerr != nil {\n\t\t\treturn heartbeatProxiedOutcome{}, fmt.Errorf(\"resolving %s: %w\", id, rerr)\n\t\t}\n\t\t// Wisps resolve here too and are refused below: the repo verb\n\t\t// classifies them ErrNotClaimable (\"is ephemeral\"), same as classic.\n\t\tif herr := uw.IssueUseCase().Heartbeat(ctx, issue.ID, actor); herr != nil {\n\t\t\treturn heartbeatProxiedOutcome{}, fmt.Errorf(\"heartbeat %s: %w\", issue.ID, herr)\n\t\t}\n\t\treturn heartbeatProxiedOutcome{id: issue.ID, title: issue.Title}, nil\n\t})\n\tif err != nil {\n\t\treturn HandleErrorRespectJSON(\"%v\", err)\n\t}\n\n\tSetLastTouchedID(res.id)\n\treturn renderHeartbeatSuccess(res.id, res.title)\n}\n","sourceCodeStart":22,"sourceCodeEnd":56,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/heartbeat_proxied_server.go#L22-L56","documentation":"Wraps any non-ErrNotFound error from workapi.GetIssueOrWisp while resolving the target issue for a proxied heartbeat. It distinguishes 'the lookup itself failed' from 'the issue does not exist'. The %w keeps the underlying storage/use-case cause.","triggerScenarios":"GetIssueOrWisp returns an error that is not storage.ErrNotFound (e.g. storage failure, ambiguous ID resolution error, driver fault) inside the heartbeat RunTxEphemeral transaction.","commonSituations":"Database lock or I/O error, driver misconfiguration in proxied mode, corrupted issue record failing unmarshalling, or transient failure during ID-prefix resolution.","solutions":["Read the wrapped cause (%v) to identify the storage-level failure.","Verify storage connectivity and DB health (bd doctor).","Retry the heartbeat; if persistent, check for corrupt records for that ID."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check DB health first\nbd doctor --json | jq -e '.storage.ok == true'","typeGuard":null,"tryCatchPattern":"if err != nil && !errors.Is(err, storage.ErrNotFound) {\n\t// transient storage failure: retry with backoff\n}","preventionTips":["Ensure the Dolt driver is healthy before issuing heartbeat commands.","Avoid concurrent processes holding long write transactions.","Watch for corrupt records; validate the DB if errors persist for one ID."],"tags":["storage","heartbeat","wrapped-error","proxied-server"],"backgroundTag":"issue-resolution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}