Hmbown/CodeWhale · error

external credential consent path for

Error message

external credential consent path for {} must be lexically normalized: {}

What it means

Thrown by `ExternalCredentialConsentToml::validate_read_scope` when `resolve_external_credential_path` on the stored path differs from the stored path itself — i.e. the path contains `..`, redundant separators, or other components that lexical normalization would remove. Consent paths must be stored pre-normalized so string comparison against the resolved path is meaningful.

Solutions

  1. Replace the consent record's `path` with its lexically normalized form (resolve `.`/`..` segments) — `resolve_external_credential_path` returns it.
  2. Revoke and re-consent so the path is captured normalized.
  3. Always run paths through the same resolver before persisting them.

Example fix

// before (consent TOML)
path = "/home/alice/projects/../.codewhale/creds/google.json"
// after
path = "/home/alice/.codewhale/creds/google.json"
Defensive patterns

Strategy: validation

Validate before calling

fn is_normalized(p: &std::path::Path) -> bool {
    // a path is lexically normalized iff resolving it yields the same string
    resolve_external_credential_path(p).map(|n| n == *p).unwrap_or(false)
}

Try / catch

match store.read_grant(provider, source, &path) {
    Err(e) if e.to_string().contains("lexically normalized") => {
        let normalized = resolve_external_credential_path(&consent.path)?;
        fix_consent_path(provider, normalized)?;
    }
    other => other,
}

Prevention

When it happens

Trigger: A consent record's `path` contains non-normalized components such as `/home/u/../u/.secrets/key` or a trailing slash / double slash; `resolve_external_credential_path(&self.path)` returns a different string than `self.path`.

Common situations: User hand-edited the consent file pasting a path with `..` segments; a script constructed the path by string concatenation instead of canonicalizing first.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/config/src/external_credentials.rs:403

                provider.as_str()
            );
        }
        if self.source != source {
            bail!(
                "external credential consent source mismatch for {} (expected {})",
                provider.as_str(),
                source.as_str()
            );
        }
        if !self.path.is_absolute() {
            bail!(
                "external credential consent path for {} must be absolute",
                provider.as_str()
            );
        }
        let normalized = resolve_external_credential_path(&self.path)?;
        if normalized != self.path {
            bail!(
                "external credential consent path for {} must be lexically normalized: {}",
                provider.as_str(),
                quote_os_path(&self.path)
            );
        }
        if self.path != resolved_path {
            bail!(
                "external credential path changed for {}; consent covers {}, current path is {}",
                provider.as_str(),
                quote_os_path(&self.path),
                quote_os_path(resolved_path)
            );
        }
        Ok(())
    }

    /// Validate and mint the read capability consumed by credential adapters.
    /// No filesystem operation occurs while validating the policy.

View on GitHub (pinned to 73e0f67d83)