gastownhall/beads · error

read adaptive id config: %w

Error message

read adaptive id config: %w

What it means

Wraps failure of cfgRepo.GetAdaptiveIDConfig during mintTopLevelID's hash-ID path. This config supplies min/max adaptive hash-length parameters; without it bd cannot size candidate IDs.

Source

Thrown at internal/storage/domain/issue.go:1617

	// because there is no wisp_counter table and ephemeral churn would make
	// a monotonic counter meaningless.
	if !useWisp {
		mode, err := u.cfgRepo.GetConfig(ctx, "issue_id_mode")
		if err != nil {
			return "", fmt.Errorf("read issue_id_mode: %w", err)
		}
		if mode == "counter" {
			n, err := u.issueRepo.NextCounterID(ctx, prefix)
			if err != nil {
				return "", err
			}
			return fmt.Sprintf("%s-%d", prefix, n), nil
		}
	}

	cfg, err := u.cfgRepo.GetAdaptiveIDConfig(ctx)
	if err != nil {
		return "", fmt.Errorf("read adaptive id config: %w", err)
	}
	tableOpts := IssueTableOpts{UseWispsTable: useWisp}

	count, err := u.issueRepo.CountForPrefix(ctx, prefix, tableOpts)
	if err != nil {
		return "", err
	}
	baseLength := ComputeAdaptiveLength(count, cfg)
	if baseLength > cfg.MaxLength {
		baseLength = cfg.MaxLength
	}

	for length := baseLength; length <= cfg.MaxLength; length++ {
		for nonce := 0; nonce < 10; nonce++ {
			candidate := idgen.GenerateHashID(prefix, issue.Title, issue.Description, actor, issue.CreatedAt, length, nonce)
			exists, err := u.issueRepo.Exists(ctx, candidate, tableOpts)
			if err != nil {
				return "", err

View on GitHub (pinned to 71377f2769)

Solutions

  1. Re-run bd init / migration to populate adaptive-ID config defaults.
  2. Verify config keys for adaptive ID exist in the config table via dolt sql.
  3. Check DB/driver connectivity and retry.
  4. Upgrade/downgrade alignment: ensure bd version matches DB schema version.
Defensive patterns

Strategy: fallback

Validate before calling

cfg, err := cfgRepo.GetAdaptiveIDConfig(ctx)
if err != nil || cfg.MaxLength == 0 {
    cfg = DefaultAdaptiveIDConfig() // sane fallback
}

Try / catch

if err != nil {
    if errors.Is(err, ErrConfigNotFound) {
        cfg = DefaultAdaptiveIDConfig() // fall back to defaults
    } else {
        return fmt.Errorf("adaptive id config unreadable: %w", err)
    }
}

Prevention

When it happens

Trigger: Minting a hash-mode ID (wisp, or regular issue when issue_id_mode != counter) while GetAdaptiveIDConfig errors: config keys absent, storage failure, canceled context.

Common situations: Workspace initialized by an older bd that predates adaptive-ID config keys; manually pruned config table; DB outage mid-create.

Related errors


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