gastownhall/beads · error

failed to update gate with discovered run ID: %w

Error message

failed to update gate with discovered run ID: %w

What it means

Wraps the storage error returned when persisting the auto-discovered numeric run ID back onto the gate (cmd/bd/gate.go:1042). Discovery succeeded, but the persistAwaitID callback (a database update of the gate's await_id) failed, so the numeric ID is not cached for future checks.

Source

Thrown at cmd/bd/gate.go:1042

	}

	// If await_id is a workflow name hint (non-numeric), auto-discover the run ID
	if !isNumericID(gate.AwaitID) {
		var discoveredID string
		var discoverErr error
		if repo == "" {
			discoveredID, discoverErr = discoverRunIDByWorkflowNameFunc(gate.AwaitID)
		} else {
			discoveredID, discoverErr = discoverRunIDByWorkflowNameInRepoWithRunner(gate.AwaitID, repo, runGH)
		}
		if discoverErr != nil {
			return false, false, fmt.Sprintf("workflow hint '%s': %v", gate.AwaitID, discoverErr), nil
		}

		if persistAwaitID != nil {
			// Non-dry-run flows persist the numeric run ID for future checks.
			if updateErr := persistAwaitID(gate.ID, discoveredID); updateErr != nil {
				return false, false, "", fmt.Errorf("failed to update gate with discovered run ID: %w", updateErr)
			}
		}

		runID = discoveredID
	}

	if repo == "" {
		return checkGHRunStatusFunc(runID)
	}
	return checkGHRunStatusInRepoWithRunner(runID, repo, runGH)
}

func checkGHRunStatus(runID string) (resolved, escalated bool, reason string, err error) {
	return checkGHRunStatusInRepo(runID, "")
}

func checkGHRunStatusInRepo(runID, repo string) (resolved, escalated bool, reason string, err error) {
	return checkGHRunStatusInRepoWithRunner(runID, repo, runGHCommand)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause (%w) for the storage-layer error message
  2. Confirm the gate still exists: `bd show <gate-id>`
  3. Retry the gate check — persistence is retried on the next evaluation
  4. Verify database connectivity and that no other process holds a conflicting write
Defensive patterns

Strategy: try-catch

Try / catch

if _, _, _, err := checkGHRun(gate); err != nil && strings.Contains(err.Error(), "failed to update gate with discovered run ID") {
    // persistence failed; the check itself may still succeed — retry or log and continue
}

Prevention

When it happens

Trigger: checkGHRunWithRunner resolves a workflow-name hint, then calls persistAwaitID(gate.ID, discoveredID) during a non-dry-run flow, and the underlying DB update returns an error (store closed, locked, concurrent modification, or write failure).

Common situations: Dolt/database connection dropped mid-operation, another process holds a conflicting write to the same issue, gate was deleted between read and update, disk or migration error in the beads store.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/aecbb7d4dbca3e5d. Report an issue: GitHub.