{"record":{"id":"245c7a7c6b325ec4","repo":"gastownhall/beads","slug":"failed-to-update-gate-with-discovered-run-id-w-245c7a","errorCode":null,"errorMessage":"failed to update gate with discovered run ID: %w","messagePattern":"failed to update gate with discovered run ID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate_proxied_server.go","lineNumber":112,"sourceCode":"\t\tprintNoOpenGates(gateTypeFilter)\n\t\treturn nil\n\t}\n\tresults := evaluateGates(ctx, filteredGates, time.Now(), proxiedFreshReadGetter{}, persistAwaitID)\n\n\tif dryRun {\n\t\tresolved, escalated, errCount := applyGateCheckResults(results, true, escalateFlag, nil)\n\t\treturn printGateCheckSummary(len(results), resolved, escalated, errCount, dryRun)\n\t}\n\n\tapplied, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (gateCheckApply, string, error) {\n\t\tout := gateCheckApply{\n\t\t\tcloseErrs: map[string]error{},\n\t\t\tawaitErrs: map[string]error{},\n\t\t}\n\n\t\tfor gateID, runID := range discovered {\n\t\t\tif err := uw.IssueUseCase().UpdateIssue(ctx, gateID, map[string]any{\"await_id\": runID}, actor); err != nil {\n\t\t\t\tout.awaitErrs[gateID] = fmt.Errorf(\"failed to update gate with discovered run ID: %w\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif after, getErr := uw.IssueUseCase().GetIssue(ctx, gateID); getErr == nil && after != nil {\n\t\t\t\tout.updated = append(out.updated, after)\n\t\t\t}\n\t\t}\n\n\t\tfor _, r := range results {\n\t\t\tif r.err != nil || !r.resolved {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif _, awaitFailed := out.awaitErrs[r.gate.ID]; awaitFailed {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbefore, _ := uw.IssueUseCase().GetIssue(ctx, r.gate.ID)\n\t\t\tif before != nil && before.Status == types.StatusClosed {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate_proxied_server.go#L94-L130","documentation":"Wraps a failure from IssueUseCase().UpdateIssue when applying a discovered workflow run ID to a gate issue via the await_id field. The discovery loop collected a run ID from GitHub Actions but the storage write to attach it to the gate failed. The error is captured per-gate in awaitErrs so other gates continue processing.","triggerScenarios":"UpdateIssue(ctx, gateID, {\"await_id\": runID}) returns an error during gate discovery apply — e.g. the gate issue was deleted after discovery, the Dolt/storage backend is unreachable, a write conflict or validation rejection occurred on the await_id update.","commonSituations":"Gate issue deleted or closed by another agent between discovery and apply; Dolt server restarted or connection dropped mid-transaction; concurrent update to the same gate causing a conflict; storage permission problem.","solutions":["Verify the gate issue still exists (`bd show <gateID>`) and re-run the discovery/apply step","Check storage health (`bd doctor`) and retry — transient Dolt/connection failures resolve on retry","Confirm no concurrent process holds a conflicting write on the gate; re-run after the other process finishes","Inspect the wrapped inner error (%w) for the exact storage failure and address it directly"],"exampleFix":"// before: gate may no longer exist when applying run ID\nif err := uw.IssueUseCase().UpdateIssue(ctx, gateID, map[string]any{\"await_id\": runID}, actor); err != nil {\n    out.awaitErrs[gateID] = fmt.Errorf(\"failed to update gate with discovered run ID: %w\", err)\n    continue\n}\n// after: pre-check existence and log the inner cause\nif _, err := uw.IssueUseCase().GetIssue(ctx, gateID); err != nil {\n    out.awaitErrs[gateID] = fmt.Errorf(\"gate %s disappeared before await_id update: %w\", gateID, err)\n    continue\n}\nif err := uw.IssueUseCase().UpdateIssue(ctx, gateID, map[string]any{\"await_id\": runID}, actor); err != nil {\n    out.awaitErrs[gateID] = fmt.Errorf(\"failed to update gate with discovered run ID: %w\", err)\n    continue\n}","handlingStrategy":"validation","validationCode":"if _, err := bdClient.Show(ctx, gateID); err != nil {\n    return fmt.Errorf(\"skip apply: gate %s no longer exists: %w\", gateID, err)\n}","typeGuard":"func gateStillExists(ctx context.Context, uc *IssueUseCase, gateID string) bool {\n    issue, err := uc.GetIssue(ctx, gateID)\n    return err == nil && issue != nil\n}","tryCatchPattern":"err := applyDiscoveredRuns(ctx, discovered)\nif err != nil {\n    for gateID, awaitErr := range awaitErrs {\n        log.Printf(\"gate %s await_id update failed: %v — verify gate exists and storage is healthy, then re-run discover\", gateID, awaitErr)\n    }\n}","preventionTips":["Do not delete gate issues between discovery and apply phases","Keep the Dolt storage backend healthy (`bd doctor`) before long discovery runs","Avoid two agents applying await_id updates to the same gate concurrently","Inspect the wrapped %w error — it names the exact storage cause"],"tags":["storage","github-actions","gate","persistence"],"backgroundTag":"gate-await-id-update-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}