Don't throw on empty variable values

https://feedback.yaak.app/p/variable-with-empty-value-in-request-will-cause-error
This commit is contained in:
Gregory Schier
2025-10-28 07:20:41 -07:00
parent c097afe657
commit 68637d24c7
2 changed files with 17 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ fn add_variable_to_map(
) -> HashMap<String, String> {
let mut map = m.clone();
for variable in variables {
if !variable.enabled || variable.value.is_empty() {
if !variable.enabled {
continue;
}
let name = variable.name.as_str();

View File

@@ -259,6 +259,22 @@ mod parse_and_render_tests {
Ok(())
}
#[tokio::test]
async fn render_empty_var() -> Result<()> {
let empty_cb = EmptyCB {};
let template = "${[ foo ]}";
let mut vars = HashMap::new();
vars.insert("foo".to_string(), "".to_string());
let opt = RenderOptions {
error_behavior: RenderErrorBehavior::Throw,
};
assert_eq!(
parse_and_render(template, &vars, &empty_cb, &opt).await,
Ok("".to_string())
);
Ok(())
}
#[tokio::test]
async fn render_self_referencing_var() -> Result<()> {
let empty_cb = EmptyCB {};