gastownhall/beads · error

LoadCreateContext: read custom statuses: %w

Error message

LoadCreateContext: read custom statuses: %w

What it means

Wrapping error from ConfigUseCaseImpl.LoadCreateContext at internal/storage/domain/config.go:261. Raised when cfgRepo.GetCustomStatuses(ctx) fails. This is the fourth read in LoadCreateContext (after prefix, allowed prefixes, custom types), so earlier reads succeeded and the failure is specific to loading custom workflow statuses.

Source

Thrown at internal/storage/domain/config.go:261

	return nil
}

func (u *configUseCaseImpl) LoadCreateContext(ctx context.Context) (CreateContext, error) {
	prefix, err := u.cfgRepo.GetConfig(ctx, "issue_prefix")
	if err != nil {
		return CreateContext{}, fmt.Errorf("LoadCreateContext: read issue_prefix: %w", err)
	}
	allowed, err := u.cfgRepo.GetAllowedPrefixes(ctx)
	if err != nil {
		return CreateContext{}, fmt.Errorf("LoadCreateContext: read allowed_prefixes: %w", err)
	}
	customTypes, err := u.cfgRepo.GetCustomTypes(ctx)
	if err != nil {
		return CreateContext{}, fmt.Errorf("LoadCreateContext: read custom types: %w", err)
	}
	customStatuses, err := u.cfgRepo.GetCustomStatuses(ctx)
	if err != nil {
		return CreateContext{}, fmt.Errorf("LoadCreateContext: read custom statuses: %w", err)
	}
	infraTypes, err := u.GetInfraTypes(ctx)
	if err != nil {
		return CreateContext{}, fmt.Errorf("LoadCreateContext: read infra types: %w", err)
	}
	return CreateContext{
		IssuePrefix:     prefix,
		AllowedPrefixes: allowed,
		CustomTypes:     customTypes,
		CustomStatuses:  customStatuses,
		InfraTypes:      infraTypes,
	}, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Unwrap the error chain to the storage cause
  2. Verify custom-statuses storage integrity
  3. Increase the context deadline if timeouts are the cause
  4. Retry LoadCreateContext once storage is stable
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check custom statuses readability with an adequate deadline
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if _, err := store.GetCustomStatuses(ctx); err != nil {
	return fmt.Errorf("custom statuses unreadable: %w", err)
}

Try / catch

cc, err := uc.LoadCreateContext(ctx)
if err != nil {
	if strings.Contains(err.Error(), "read custom statuses") && errors.Is(err, context.DeadlineExceeded) {
		// deadline hit late in the multi-read sequence; retry with longer budget
		longCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
		defer cancel()
		cc, err = uc.LoadCreateContext(longCtx)
	}
	if err != nil {
		return err
	}
}

Prevention

When it happens

Trigger: Calling LoadCreateContext when GetCustomStatuses fails — storage query error, dropped connection partway through the multi-read sequence, or context cancellation.

Common situations: Long-running LoadCreateContext hitting a context deadline on slow storage; corrupted custom-status rows; DB restarted between reads.

Related errors


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