Skip to main content

compute_and_ensure_bundle_dir

Function compute_and_ensure_bundle_dir 

Source
pub(crate) fn compute_and_ensure_bundle_dir(
    into_bundle_id: Option<&str>,
    provider_id: &str,
    auth_env: &mut HashMap<String, String>,
) -> Option<String>
Expand description

Compute the per-bundle OAuth config dir + ensure it exists + override the provider’s auth_config_dir_env_var entry in auth_env.

Returns Some(<absolute path string>) when:

  • into_bundle_id is Some and non-empty AND
  • the provider is registered in the CLI provider registry AND
  • the provider declares an auth_config_dir_env_var (oauth-class providers per identity::resolver::provider_class — claude / codex / openclaw / gemini / copilot as of REPORT_AUTH_ARCHITECTURE_STATE_AND_RETHINK_2026_07_21.md §2.5/§6) AND
  • DataPaths::from_env() resolves AND
  • create_dir_all succeeds.

Otherwise returns None and leaves auth_env untouched. Callers must continue without per-bundle isolation (legacy ambient path, or skip the binding-persist step) — never abort the OAuth start.

Per docs/specs/archive/SPEC_OAUTH_IDENTITY_BUNDLES_2026_05_22.md §4.5: the dir (and the env-var key) come from the CLI provider registry (backend::providers::get_provider(id)) so the resolver / spawn path / OAuth-start handler never drift on which env var redirects each CLI’s config home. The single source of truth lives in crates/srv/src/backend/providers.rs.