Skip to content

fix: three bugs in Jinja templater Python bridge#2587

Open
plasorak-nr wants to merge 2 commits into
quarylabs:mainfrom
plasorak-nr:fix/jinja-loader-search-path-and-ignore-templating
Open

fix: three bugs in Jinja templater Python bridge#2587
plasorak-nr wants to merge 2 commits into
quarylabs:mainfrom
plasorak-nr:fix/jinja-loader-search-path-and-ignore-templating

Conversation

@plasorak-nr
Copy link
Copy Markdown

Summary

This PR fixes three bugs in the Python Jinja templater that cause runtime errors when using loader_search_path or ignore_templating with the Jinja templater.

Fixes

jinja_loader_search_path type mismatch between Rust and Python (python_shared.rs)

The PythonFluffConfig Rust struct serialised jinja_loader_search_path as Option (i.e. null or a bare JSON string). However, the Python FluffConfig NamedTuple declares the field as List[str], so deserialisation via FluffConfig(**json.loads(...)) raised a TypeError at runtime whenever a loader_search_path was configured.

Fix: Changed the Rust field to Vec and updated the From<&FluffConfig> conversion to collect the config value into a vec, handling both single-string and array config values gracefully. Updated the unit test assertion accordingly.

process_from_rust raises ValueError even when ignore_templating = true (jinja_templater.py)

process_from_rust raised ValueError unconditionally whenever the templater returned any errors, ignoring the user's ignore_templating configuration. This made it impossible to lint Jinja templates that produce templating warnings (e.g. undefined variables used inside conditional blocks) even when the user had explicitly opted in to ignoring such warnings.

Fix: Added a check against config.jinja_ignore_templating before raising, so templating errors are only fatal when the user has not configured them to be ignored.

SQLTemplaterError does not accept line_no / line_pos (python_templater.py)

jinja_templater.py constructs SQLTemplaterError with line_no=1, line_pos=1 arguments, but SQLTemplaterError.__init__ only accepted message, causing a TypeError.

Fix: Added optional line_no and line_pos parameters to SQLTemplaterError.__init__.

Pierre Lasorak added 2 commits May 1, 2026 17:17
…ating in process_from_rust

Two bugs fixed:

1. python_shared.rs: jinja_loader_search_path was serialised as
   Option<String> (null or a single string) but the Python FluffConfig
   NamedTuple declared it as List[str], causing a TypeError when
   fluff_config_from_json constructed the NamedTuple. Changed the Rust
   struct field to Vec<String> and updated the From<&FluffConfig> impl
   to collect the config value into a vec (handling both single-string
   and array config values). Updated the unit test assertion accordingly.

2. jinja_templater.py: process_from_rust raised ValueError whenever
   the templater returned any errors, even when the user had configured
   ignore_templating = true. Added a check against
   config.jinja_ignore_templating so templating warnings are suppressed
   when that flag is set.
jinja_templater.py passes line_no and line_pos keyword arguments when
constructing SQLTemplaterError, but the class only accepted message,
causing a TypeError at runtime. Added optional line_no and line_pos
parameters (matching the signature used at the call site).
@plasorak-nr plasorak-nr changed the title Title: fix: three bugs in Jinja templater Python bridge Bugfix: three bugs in Jinja templater Python bridge May 1, 2026
@plasorak-nr plasorak-nr changed the title Bugfix: three bugs in Jinja templater Python bridge fix: three bugs in Jinja templater Python bridge May 5, 2026
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.

1 participant