Skip to content

Commit 9203f6a

Browse files
authored
Fix bug where empty string for boundary_base_url would not set the default url (#1971)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Fixes bug in `Config` where empty strings for certain fields would not set default values by adding a `normalize()` function. > > - **Behavior**: > - Fixes bug where empty `base_url` in `Config` would not set default URL by adding `normalize()` function. > - `normalize()` sets default values for `base_url`, `sessions_id`, `stage`, `host_name`, and `log_redaction_placeholder` if they are empty. > - **Functions**: > - Adds `normalize()` to `Config` in `env_setup.rs` to handle default value assignment. > - **Misc**: > - Calls `normalize()` in `from_env_vars()` to ensure defaults are set after parsing environment variables. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 21d68da. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent 1cb4648 commit 9203f6a

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

engine/baml-runtime/src/tracing/api_wrapper/env_setup.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,31 @@ impl Config {
5757
.from_iter(env_vars.map(|(k, v)| (k.as_ref().to_string(), v.as_ref().to_string())));
5858

5959
match config {
60-
Ok(config) => Ok(config),
60+
Ok(config) => Ok(config.normalize()),
6161
Err(err) => Err(anyhow::anyhow!(
6262
"Failed to parse config from environment variables: {}",
6363
err
6464
)),
6565
}
6666
}
67+
68+
pub fn normalize(mut self) -> Self {
69+
if self.base_url.is_empty() {
70+
self.base_url = default_base_url();
71+
}
72+
if self.sessions_id.is_empty() {
73+
self.sessions_id = default_sessions_id();
74+
}
75+
if self.stage.is_empty() {
76+
self.stage = default_stage();
77+
}
78+
if self.host_name.is_empty() {
79+
self.host_name = default_host_name();
80+
}
81+
if self.log_redaction_placeholder.is_empty() {
82+
self.log_redaction_placeholder = default_redaction_placeholder();
83+
}
84+
// max_log_chunk_chars is usize, so no need to check for empty string
85+
self
86+
}
6787
}

0 commit comments

Comments
 (0)