mirror of
https://github.com/openai/codex.git
synced 2026-04-29 17:06:51 +00:00
login: treat provider auth refresh_interval_ms=0 as no auto-refresh (#16480)
## Why Follow-up to #16288: the new dynamic provider auth token flow currently defaults `refresh_interval_ms` to a non-zero value and rejects `0` entirely. For command-backed bearer auth, `0` should mean "never auto-refresh". That lets callers keep using the cached token until the backend actually returns `401 Unauthorized`, at which point Codex can rerun the auth command as part of the existing retry path. ## What changed - changed `ModelProviderAuthInfo.refresh_interval_ms` to accept `0` and documented that value as disabling proactive refresh - updated the external bearer token refresher to treat `refresh_interval_ms = 0` as an indefinitely reusable cached token, while still rerunning the auth command during unauthorized recovery - regenerated `core/config.schema.json` so the schema minimum is `0` and the new behavior is described in the field docs - added coverage for both config deserialization and the no-auto-refresh plus `401` recovery behavior ## How tested - `cargo test -p codex-protocol` - `cargo test -p codex-login` - `cargo test -p codex-core test_deserialize_provider_auth_config_`
This commit is contained in:
@@ -283,8 +283,9 @@ pub struct ModelProviderAuthInfo {
|
||||
pub timeout_ms: NonZeroU64,
|
||||
|
||||
/// Maximum age for the cached token before rerunning the command.
|
||||
/// Set to `0` to disable proactive refresh and only rerun after a 401 retry path.
|
||||
#[serde(default = "default_provider_auth_refresh_interval_ms")]
|
||||
pub refresh_interval_ms: NonZeroU64,
|
||||
pub refresh_interval_ms: u64,
|
||||
|
||||
/// Working directory used when running the token command.
|
||||
#[serde(default = "default_provider_auth_cwd")]
|
||||
@@ -297,8 +298,8 @@ impl ModelProviderAuthInfo {
|
||||
Duration::from_millis(self.timeout_ms.get())
|
||||
}
|
||||
|
||||
pub fn refresh_interval(&self) -> Duration {
|
||||
Duration::from_millis(self.refresh_interval_ms.get())
|
||||
pub fn refresh_interval(&self) -> Option<Duration> {
|
||||
NonZeroU64::new(self.refresh_interval_ms).map(|value| Duration::from_millis(value.get()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,11 +310,8 @@ fn default_provider_auth_timeout_ms() -> NonZeroU64 {
|
||||
)
|
||||
}
|
||||
|
||||
fn default_provider_auth_refresh_interval_ms() -> NonZeroU64 {
|
||||
non_zero_u64(
|
||||
DEFAULT_PROVIDER_AUTH_REFRESH_INTERVAL_MS,
|
||||
"model_providers.<id>.auth.refresh_interval_ms",
|
||||
)
|
||||
fn default_provider_auth_refresh_interval_ms() -> u64 {
|
||||
DEFAULT_PROVIDER_AUTH_REFRESH_INTERVAL_MS
|
||||
}
|
||||
|
||||
fn non_zero_u64(value: u64, field_name: &str) -> NonZeroU64 {
|
||||
|
||||
Reference in New Issue
Block a user