Hmbown/CodeWhale · error

The active route has no exact provider config identity.

Error message

The active route has no exact provider config identity.

What it means

When persisting the active route, the app needs an exact provider config identity string. `provider_identity_for_persistence()` is only produced when the active provider is Custom (case-insensitive match on the stored identity); for any other provider, or when no identity is stored, the Option is None and this error is returned.

Solutions

  1. Select/enter the custom provider's identity before persisting the route
  2. Only call route persistence for Custom providers with a set identity
  3. Provide the provider identity via set_provider_identity before persisting

Example fix

// before
app.set_provider(ApiProvider::Anthropic);
app.persist_route();  // errors: no custom identity
// after
app.set_provider(ApiProvider::Custom);
app.set_provider_identity(ApiProvider::Custom, "my-gateway");
app.persist_route();
Defensive patterns

Strategy: validation

Validate before calling

if (app.provider !== 'custom' || !app.providerIdentity) {
  throw new Error('route persistence requires a custom provider with an identity');
}

Type guard

const canPersistRoute = (app) => String(app.providerIdentity ?? '').trim() !== '' && app.provider.toLowerCase() === 'custom';

Prevention

When it happens

Trigger: Calling the route-persistence accessor while the active provider is not `ApiProvider::Custom`, or it is Custom but `provider_identity` is empty/unset so the `.then(...)` yields None.

Common situations: Trying to persist a startup default while on a built-in provider (Anthropic/OpenAI) that has no custom identity; a custom provider selected but its identity field never filled in; state restored from a session where identity was lost.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/19f83b55d3a8ed2a. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tui/app.rs:6277

    #[must_use]
    pub(crate) fn provider_id_for_persistence(&self) -> Option<&str> {
        self.provider_exact_id.as_deref()
    }

    /// Config selectors retain the exact saved slot, including legacy hosted
    /// Ollama's `ollama` slot. Session receipts keep their canonical identity.
    pub(crate) fn provider_selector_for_config_persistence(&self) -> anyhow::Result<&str> {
        self.provider_id_for_persistence()
            .or_else(|| {
                (self.api_provider == ApiProvider::Custom
                    && self
                        .provider_identity
                        .eq_ignore_ascii_case(ApiProvider::Custom.as_str()))
                .then(|| self.provider_identity_for_persistence())
            })
            .ok_or_else(|| {
                anyhow::anyhow!("The active route has no exact provider config identity.")
            })
    }

    pub(crate) fn set_provider_identity(
        &mut self,
        provider: ApiProvider,
        identity: impl Into<String>,
    ) {
        let identity = identity.into();
        self.api_provider = provider;
        self.provider_exact_id = (!(provider == ApiProvider::Custom
            && identity.eq_ignore_ascii_case(ApiProvider::Custom.as_str())))
        .then(|| identity.clone());
        self.provider_identity = identity;
    }

    pub(crate) fn set_provider_identity_record(
        &mut self,

View on GitHub (pinned to 73e0f67d83)