Skip to content

fix: restore get_env() template function - #577

Merged
maxdymond merged 1 commit into
mainfrom
md/fix-get-env
Aug 7, 2026
Merged

fix: restore get_env() template function#577
maxdymond merged 1 commit into
mainfrom
md/fix-get-env

Conversation

@maxdymond

@maxdymond maxdymond commented Aug 7, 2026

Copy link
Copy Markdown
Member

Fixes #576.

tera 2 dropped the built-in get_env(), so floki.yaml files using it stopped rendering as of floki 2.4.4:

[ERROR] A problem occurred: There was a problem rendering the template 'floki.yaml': Unknown function `get_env`

The fix

Reimplement get_env as a custom tera function and register it alongside the existing yaml/json/toml loaders. Same signature as tera 1: get_env(name="HOME"), with an optional default used when the variable is unset, and an error otherwise.

CI coverage

Three unit tests in src/config.rs cover the set, defaulted, and missing-and-no-default cases. cargo test already runs on every PR, so a future tera bump that drops get_env again fails the build rather than shipping.

Docs updated to mention get_env alongside the existing env.* example.

tera 2 dropped the built-in get_env(), so floki.yaml files using it
stopped rendering as of 2.4.4. Reimplement and register it, with tests
so a future tera bump can't silently drop it again.

Fixes #576

Signed-off-by: Max Dymond <max.dymond@alianza.com>
@maxdymond
maxdymond added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit b62bd95 Aug 7, 2026
8 checks passed
@maxdymond
maxdymond deleted the md/fix-get-env branch August 7, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_env() function in templated floki files no longer works from version 2.4.4 onwards

1 participant