gastownhall/beads · error

LoadCreateContext: read issue_prefix: %w

Error message

LoadCreateContext: read issue_prefix: %w

What it means

Wrapping error from ConfigUseCaseImpl.LoadCreateContext in internal/storage/domain/config.go:249. It fires when reading the 'issue_prefix' config value via cfgRepo.GetConfig fails. LoadCreateContext assembles everything needed to create issues (prefix, allowed prefixes, custom types/statuses, infra types); this is the first read in that sequence, so a storage failure aborts issue creation early.

Source

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

func (u *configUseCaseImpl) SetMetadata(ctx context.Context, key, value string) error {
	if err := u.cfgRepo.SetMetadata(ctx, key, value); err != nil {
		return fmt.Errorf("SetMetadata: %w", err)
	}
	return nil
}

func (u *configUseCaseImpl) SetLocalMetadata(ctx context.Context, key, value string) error {
	if err := u.cfgRepo.SetLocalMetadata(ctx, key, value); err != nil {
		return fmt.Errorf("SetLocalMetadata: %w", err)
	}
	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{

View on GitHub (pinned to 71377f2769)

Solutions

  1. Unwrap to see the storage-level cause
  2. Confirm the database is reachable and the config table is readable
  3. Verify 'issue_prefix' config storage isn't corrupted (run bd doctor / storage checks)
  4. Retry LoadCreateContext once storage is healthy
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm storage is healthy before loading create context
if err := uc.Ping(ctx); err != nil {
	return fmt.Errorf("cannot create issue: storage unreachable: %w", err)
}

Try / catch

cc, err := uc.LoadCreateContext(ctx)
if err != nil {
	if strings.Contains(err.Error(), "read issue_prefix") && errors.Is(err, context.DeadlineExceeded) {
		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
		defer cancel()
		cc, err = uc.LoadCreateContext(ctx)
	}
	if err != nil {
		return err
	}
}

Prevention

When it happens

Trigger: Calling LoadCreateContext when cfgRepo.GetConfig(ctx, "issue_prefix") returns a non-nil error — DB unavailable, query failure, cancelled context.

Common situations: First bd create command after the DB was moved or corrupted; database server down; stale connection pool after a network blip.

Related errors


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