multica-ai/multica · warning

invalid runtime provider summary

Error message

invalid runtime provider summary

What it means

Two paths inside validateClientUsageRuntime produce 'invalid runtime provider summary': (a) a provider key that fails providerNamePattern, or a per-provider count outside 0..1000; (b) json.Marshal of the (already unmarshaled) summary map fails, which for map[string]Int is effectively unreachable but kept as a guard. Path (a) is the real-world one: provider names must match the expected name pattern and each provider's count must be a plausible non-negative integer within the same cap as runtime_count.

Source

Thrown at server/internal/handler/client_usage.go:211

		if probe.RuntimeCount != nil || probe.ProviderSummary != nil || probe.OnlineCount != nil || probe.OfflineCount != nil {
			return validatedRuntimeProbe{}, errors.New("failed runtime probes must not include counts")
		}
		return validated, nil
	}

	if probe.RuntimeCount == nil || probe.ProviderSummary == nil || probe.OnlineCount == nil || probe.OfflineCount == nil {
		return validatedRuntimeProbe{}, errors.New("successful runtime probes require all counts")
	}
	if *probe.RuntimeCount < 0 || *probe.RuntimeCount > 1000 || *probe.OnlineCount < 0 || *probe.OfflineCount < 0 || *probe.OnlineCount+*probe.OfflineCount != *probe.RuntimeCount {
		return validatedRuntimeProbe{}, errors.New("invalid runtime counts")
	}
	if len(probe.ProviderSummary) > 32 {
		return validatedRuntimeProbe{}, errors.New("too many runtime providers")
	}
	var providerTotal int64
	for provider, count := range probe.ProviderSummary {
		if !providerNamePattern.MatchString(provider) || count < 0 || count > 1000 {
			return validatedRuntimeProbe{}, errors.New("invalid runtime provider summary")
		}
		providerTotal += int64(count)
	}
	if providerTotal != int64(*probe.RuntimeCount) {
		return validatedRuntimeProbe{}, errors.New("runtime provider counts do not match runtime_count")
	}
	summary, err := json.Marshal(probe.ProviderSummary)
	if err != nil {
		return validatedRuntimeProbe{}, errors.New("invalid runtime provider summary")
	}
	validated.RuntimeCount = pgtype.Int4{Int32: *probe.RuntimeCount, Valid: true}
	validated.ProviderSummary = summary
	validated.OnlineCount = pgtype.Int4{Int32: *probe.OnlineCount, Valid: true}
	validated.OfflineCount = pgtype.Int4{Int32: *probe.OfflineCount, Valid: true}
	return validated, nil
}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Use plain, stable provider identifiers as keys (same vocabulary as the platform's provider names).
  2. Validate each entry client-side: name matches the provider pattern and 0 <= count <= 1000.
  3. Recompute per-provider counts from the same snapshot used for runtime_count.
  4. Strip dynamic suffixes from provider names before summarizing.

Example fix

// before
summary[`${provider} @ ${endpoint}`] += 1;

// after
summary[provider] += 1; // bare provider name, count within 0..1000
Defensive patterns

Strategy: validation

Validate before calling

const PROVIDER_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_.-]{0,63}$/; // align with server pattern

function assertProviderSummary(summary) {
  for (const [name, count] of Object.entries(summary)) {
    if (!PROVIDER_NAME_RE.test(name)) throw new TypeError(`provider name ${JSON.stringify(name)} fails pattern`);
    if (!Number.isInteger(count) || count < 0 || count > 1000) throw new RangeError(`provider ${name} count ${count} out of [0,1000]`);
  }
}

Type guard

const isValidProviderEntry = ([name, count]) => PROVIDER_NAME_RE.test(name) && Number.isInteger(count) && count >= 0 && count <= 1000;

Prevention

When it happens

Trigger: POST a success probe with a provider key containing spaces, slashes, or leading digits (whatever providerNamePattern disallows), or with {"openai": -1} or {"openai": 2000} per-provider counts.

Common situations: Embedding versions/URLs/usernames in provider keys ('openai/v1', 'my org'); negative counts from a diffing bug; per-provider counts computed against a different snapshot than the total so one bucket exceeds 1000 after merging.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/d9ba5f7d96735285. Report an issue: GitHub.