Skip to content

Commit

Permalink
feat: enhance error handling for unset env variables in property.json (
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn authored Dec 1, 2024
1 parent 0d78527 commit 616df9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@
"name": "app (C/C++) (lldb, launch)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/cpp_app_multi_process_python/cpp_app_multi_process_python_app/bin/cpp_app_multi_process_python_app_source",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/graph_env_var_3/graph_env_var_3_app/bin/graph_env_var_3_app_source",
"args": [],
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/cpp_app_multi_process_python/cpp_app_multi_process_python_app/",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/graph_env_var_3/graph_env_var_3_app",
"env": {
"ASAN_OPTIONS": "use_sigaltstack=0",
},
Expand Down
13 changes: 9 additions & 4 deletions core/src/ten_utils/lib/sys/general/placeholder.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,21 @@ bool ten_placeholder_resolve(ten_placeholder_t *self,
// Environment variable not found, use default value.
if (!ten_value_is_valid(&self->default_value)) {
// If no default value is provided, use 'null' value.
TEN_LOGI(
TEN_LOGE(
"Environment variable %s is not found, neither default value is "
"provided, set property to null.",
"provided.",
variable_name);
exit(-1);

ten_value_reset_to_null(placeholder_value);
} else {
TEN_LOGI("Environment variable %s is not found, using default value.",
variable_name);
const char *default_value =
ten_value_peek_raw_str(&self->default_value);

TEN_LOGI(
"Environment variable %s is not found, using default value %s.",
variable_name, default_value);

ten_value_reset_to_string_with_size(placeholder_value, default_value,
strlen(default_value));
}
Expand Down

0 comments on commit 616df9f

Please sign in to comment.