Skip to content

Commit 0896274

Browse files
duanbingclaude
andcommitted
fix(amux): fall back to default base when AMUX_API_BASE is empty
env::var returns Ok("") for an env var set to an empty string (as docker-compose passes ${AMUX_API_BASE:-} when unset), which would yield an empty base URL. Filter empties so https://api.amux.ai still wins. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1e9dc55 commit 0896274

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • tensorzero-core/src/providers

tensorzero-core/src/providers/amux.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ const REQUEST_TIMEOUT: Duration = Duration::from_secs(300);
2323
const ASYNC_TASK_TIMEOUT: Duration = Duration::from_secs(3600);
2424

2525
lazy_static! {
26-
static ref AMUX_API_BASE: String =
27-
std::env::var("AMUX_API_BASE").unwrap_or_else(|_| "https://api.amux.ai".to_string());
26+
// `unwrap_or_else` only fires on `Err`; an env var set to an empty string
27+
// (e.g. docker-compose's `AMUX_API_BASE: ${AMUX_API_BASE:-}` when unset)
28+
// comes back as `Ok("")` and would otherwise become an empty base URL.
29+
// Filter empties so the public default still wins.
30+
static ref AMUX_API_BASE: String = std::env::var("AMUX_API_BASE")
31+
.ok()
32+
.filter(|s| !s.is_empty())
33+
.unwrap_or_else(|| "https://api.amux.ai".to_string());
2834
}
2935

3036
pub struct AmuxProvider;

0 commit comments

Comments
 (0)