gastownhall/beads · error

failed to check parent issue: %w

Error message

failed to check parent issue: %w

What it means

When CreateIssueFromFormValues checks the parent via s.GetIssue, any error that is NOT storage.ErrNotFound (network/driver failure, DB corruption, permission error) is wrapped as "failed to check parent issue: %w" so the underlying storage error is preserved. It distinguishes 'parent definitely missing' (308) from 'could not determine whether it exists'.

Source

Thrown at cmd/bd/create_form.go:111

		Dependencies:       deps,
	}
}

// CreateIssueFromFormValues creates an issue from the given form values.
// It returns the created issue and any error that occurred.
// This function handles parent-child relationships, labels, dependencies,
// and source_repo inheritance.
func CreateIssueFromFormValues(ctx context.Context, s storage.DoltStorage, fv *createFormValues, actor string) (*types.Issue, error) {
	// If parent is specified, validate it exists and generate child ID
	var explicitID string
	var inheritedLabels []string
	if fv.ParentID != "" {
		_, err := s.GetIssue(ctx, fv.ParentID)
		if err != nil {
			if errors.Is(err, storage.ErrNotFound) {
				return nil, fmt.Errorf("parent issue %s not found", fv.ParentID)
			}
			return nil, fmt.Errorf("failed to check parent issue: %w", err)
		}
		childID, err := s.GetNextChildID(ctx, fv.ParentID)
		if err != nil {
			return nil, fmt.Errorf("failed to generate child ID: %w", err)
		}
		explicitID = childID
		ctx = storage.WithReservedChildCounter(ctx, fv.ParentID, childID)

		// Inherit parent labels (GH#2100), matching bd create --parent behavior
		inheritedLabels, _ = s.GetLabels(ctx, fv.ParentID)
	}

	var externalRefPtr *string
	if fv.ExternalRef != "" {
		externalRefPtr = &fv.ExternalRef
	}

	labels := mergeCreateLabels(fv.Labels, inheritedLabels)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped %w cause with `bd doctor` or by inspecting the full error output and fix the storage-layer issue first
  2. Retry after confirming the database is healthy (`bd doctor`, `bd dolt pull`/status)
  3. If the parent lookup keeps failing, create without a parent and attach later once storage recovers

Example fix

// before
// opaque failure: fv.ParentID set, storage driver down
// after
// diagnose first, then create:
//   bd doctor
//   bd show <parent-id>   # confirm storage works
//   bd create "Task" --parent <parent-id>
Defensive patterns

Strategy: try-catch

Validate before calling

if err := exec.Command("bd", "doctor").Run(); err != nil {
    return fmt.Errorf("storage unhealthy; fix before creating child issues")
}

Try / catch

err := runCreateForm(...)
if err != nil {
    var notFound bool
    if strings.Contains(err.Error(), "parent issue ") && strings.Contains(err.Error(), "not found") {
        notFound = true // error 308 path
    }
    if strings.HasPrefix(err.Error(), "failed to check parent issue:") {
        // storage-layer failure: log full cause, back off and retry
        log.Printf("storage check failed: %v", err)
    }
    _ = notFound
}

Prevention

When it happens

Trigger: Calling CreateIssueFromFormValues / runCreateForm with fv.ParentID set while the storage backend fails for a non-NotFound reason: Dolt driver connection errors, locked/corrupt DB, context cancellation mid-query.

Common situations: Embedded-mode or driver outages during form submit; running bd while another process holds the database in a bad state; transient storage failures in scripts that retry-able fix.

Related errors


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