Skip to content

chore: bump minijinja from 2.24.0 to 3.0.0 - #4442

Merged
max-sixty merged 5 commits into
mainfrom
dependabot/cargo/minijinja-3.0.0
Oct 14, 2026
Merged

max-sixty merged 5 commits into
mainfrom
dependabot/cargo/minijinja-3.0.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Oct 12, 2026

Copy link
Copy Markdown
Contributor

Bumps minijinja from 2.24.0 to 3.0.0.

Changelog

Sourced from minijinja's changelog.

3.0.0

MiniJinja 3 is a major release. It aligns template behavior and the value model more closely with Jinja2, makes Serde optional, makes mutable State the canonical way to call back into the engine, adds built-in automatic reloading of templates, reworks the JavaScript bindings and makes the Python bindings considerably faster. Errors involving undefined values and the debug info shown for errors were improved as well.

Most projects will need some changes when upgrading. See UPDATING.md for migration instructions. The changes below are relative to 2.24.0 and include everything from the 3.0.0 alpha releases.

Breaking Changes

  • Made serde optional, explicit and disabled by default. The rendering APIs, context! and args! now consume values and convert exclusively through Into<Value>. Serde conversion is requested with the new value::Serde wrapper which also replaces ViaDeserialize for deserializing function arguments. Value::from_serialize was removed. The deserialization feature was removed and is now part of the serde feature. Disabling the feature fully removes the dependency. #528
  • The json feature no longer depends on serde and serde_json. The tojson filter and JSON auto escaping now use a built-in JSON serializer. Invalid values now fail the serialization rather than being emitted as null. Floats are formatted like recent versions of serde_json do (for instance 1e+16 instead of 1e16). The speedups feature now uses zmij and itoa to format numbers in JSON; the output is the same without it.
  • Made mutable State the canonical path for functions, filters, tests, objects, methods, formatters, unknown method callbacks and nested macro calls. Read-only typed callbacks can continue to use &State; state mutation and dynamic calls now require &mut State. Added typed render-local extensions that persist through includes, blocks and macros. State::get_or_set_temp_object was removed in favor of these extensions.
  • Removed Rust APIs deprecated before 3.0: Template::render_and_return_state, Template::render_to_write, Template::eval_to_state, the Filter, Test, TestResult and ViaDeserialize aliases, value::intern and the no-op key_interning feature. The no-op loader feature was also removed; loader APIs remain available unconditionally.
  • Moved format_filter and FormatStyle from the crate root into the new formatting module and renamed format_filter to formatting::format.
  • Moved the trim_blocks, lstrip_blocks and keep_trailing_newline settings from Environment into SyntaxConfig. Added SyntaxConfig::to_builder to modify an existing configuration. Template introspection via Template::undeclared_variables now honors the whitespace settings. WhitespaceConfig was removed from the unstable_machinery APIs. #470
  • Removed the custom_syntax feature. Custom delimiters, line statements and line comments are now always available. The aho-corasick dependency was removed; start markers are now found with a simple scan which is as fast or faster and makes building a custom SyntaxConfig about 100 times faster.
  • Empty end delimiters are now rejected with ErrorKind::InvalidDelimiter.
  • Changed AutoEscape::Custom to hold a Cow<'static, str> so custom auto escape formats can be determined at runtime. AutoEscape is no longer Copy and State::auto_escape now returns a reference.
  • Changed Value function arguments to reject implicit keyword-argument values. Variadic functions that intentionally capture them can use ValueOrKwargs. #596
  • Added native Rust tuple conversions and Value::from_pairs. Collecting pairs directly into Value now creates a sequence of tuples rather than a map.
  • Iteration now consistently fails on invalid values that iterators yield to report errors. Previously only loops did this while filters such as list, join or sort, the in operator and serialization processed them like other items. The new ValueIter::checked helper provides the same behavior for custom code.
  • Environment::set_loader is now generic over the returned source, which can be a String or a TemplateSource. Closures that relied on type inference through .into() or only return Ok(None) need an explicit type.
  • Discontinued the minijinja-autoreload crate in favor of built-in automatic reloading (see below).

Template Behavior

These changes apply to Rust and Go and therefore also to the Python and JavaScript bindings.

  • Added first-class tuple literals and public tuple value types. Tuples now preserve their type through serialization and sequence operations, render like Python tuples, and roundtrip as tuples through the Python bindings. JavaScript receives evaluated tuples as arrays. #785
  • Changed sequence and map representations to use Python-style string quoting, and changed tojson to use Jinja2-compatible separator spacing. #785
  • Changed floor division and modulo to match Jinja2 semantics. #935
  • Changed division by zero to produce an error. #949
  • Changed the round filter to use round-half-even semantics and fixed decimal rounding edge cases. #948
  • Changed built-ins to treat booleans as numbers for Jinja2 compatibility. #950
  • Changed the sequence test to classify undefined values as sequences. #951
  • Fixed the upper and lower tests to reject non-strings and handle titlecase characters correctly. #952
  • Fixed the title filter treating every ASCII punctuation character as a word boundary. Words now start after whitespace or one of -, (, {, [ and < as in Jinja2, so "don't"|title renders as Don't instead of Don'T. #930
  • Fixed the precedence of unary minus. Like in Jinja2, -foo.bar now negates foo.bar rather than looking up bar on -foo.
  • Fixed the format filter accepting undefined values with strict and semi-strict undefined behavior.
  • Fixed constant-folded and and or expressions returning booleans instead of preserving their operands. #945
  • Added support for format precisions beyond Rust's formatter limit. #946
  • Limited repeated sequence sizes to prevent excessive allocations. #947
  • Fixed custom delimiters where a start marker overlaps a longer one (for instance <% and <%%=) sometimes picking the wrong marker.

... (truncated)

Commits
  • c1e7e23 chore(release): 3.0.0
  • 7a8f76b docs(changelog): consolidate the 3.0.0 alpha entries
  • c123ab4 docs: complete the MiniJinja 3 upgrade guide
  • 7a92676 feat(playground): add an empty example
  • 1be8515 feat(playground): add a console tab for logged messages
  • 85e5206 fix(playground): replace empty configs with the default config
  • de65258 feat(playground): use commented out examples as default config
  • 2d95b1f feat(playground): add config tab and preview mode toggle
  • 2e76f5e feat(playground): align colors with the MiniJinja logo
  • 3982db0 fix(ci): exclude minijinja-js from MSRV builds
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot Bot added dependencies Pull requests that update a dependency file rust Pull requests that update rust code labels Oct 12, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minijinja 3.0 removed or changed six APIs that worktrunk calls, so the bump doesn't compile, and each build, lint, and test job that has finished on this head failed on those errors. I'm pushing the migration to this branch:

  • Value::from_serialize → Value::from(Serde(..)) for parsed JSON vars. Plain maps now use Value::from.
  • Environment::set_keep_trailing_newline → rebuild the env's SyntaxConfig with keep_trailing_newline(true).
  • machinery::parse dropped its whitespace-config argument.
  • The new Expr::Tuple AST variant gets a read-visiting arm in TemplateVars. Assignment targets still parse as List, so bound detection is unchanged. The existing {% set a = 1, repo_root %} normalization test exercises the new arm.
  • 3.0 names the undefined expression in its error detail (undefined value: `vars.missing` is undefined), so test_undefined_namespace_values_do_not_name_unreached_typos now pins the expected name for each template. Each case still names the expression actually reached, never the unreached brnch typo.

A decision for a maintainer before merging: 3.0 also changes template semantics to match Jinja2, and those changes reach users' hook, alias, and prompt templates. Sequences and maps now render with Python-style quotes, tojson uses Jinja2 spacing, division by zero is an error, round rounds half to even, and // and % follow Jinja2 semantics. No template in this repo's docs or examples depends on these, and the integration suite produced no snapshot changes, but a user template that prints a list or relies on those operators renders differently after upgrading.

- Value::from_serialize -> Value::from(Serde(..)) / Value::from
- set_keep_trailing_newline -> SyntaxConfig::to_builder().keep_trailing_newline(true)
- machinery::parse dropped its whitespace-config argument
- visit the new Expr::Tuple variant in TemplateVars
- pin minijinja 3's undefined-value detail, which names the reached expression
MiniJinja names the undefined expression only when Environment::debug()
is on, which defaults to debug_assertions, so the nix-flake check (a
release build) saw the bare message.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Pushed the minijinja 3 migration (f6973e73a) plus a follow-up (cad0a97b7): the undefined-value detail is debug-only, since Environment::debug() defaults to debug_assertions, so the release-profile nix-flake tests saw the bare message. The rest of CI is green at cad0a97b7 except two checks, neither from this change:

  • codecov/patch (97.95% vs 98.49%): the only uncovered added line is the release-only else arm in test_undefined_namespace_values_do_not_name_unreached_typos. The coverage job builds in debug, and nix-flake runs that arm in release and passes. Per AGENTS.md, merging over this needs explicit maintainer approval.
  • check-unused-dependencies: cargo-udeps reports dirs unused on Linux. refactor: stop refining failed forge calls and missing nu/pwsh #4436 (397136ea3) removed its last non-Windows use (dirs::data_dir() in the nushell paths), leaving only the #[cfg(windows)] dirs::document_dir() call in powershell_profile_paths. That commit landed after main's last green nightly, so main has the same failure.

So release builds keep today's undefined value @ line 1 message, and only debug builds name the expression. Calling env.set_debug(true) in template_environment would give users the more specific message too, at minijinja's documented cost of tracking debug state on every render. That's a product choice, so I left it out of this PR.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minijinja 3 migration looks right. Its one gap is the debug/release branch in test_undefined_namespace_values_do_not_name_unreached_typos, and that branch is what keeps codecov/patch red (see the inline suggestion). I'm pushing that change to this branch. The template-semantics decision raised in the earlier review is still open for a maintainer.

Comment thread src/config/expansion.rs Resolved
The cfg!(debug_assertions) else arm only ran in release builds, leaving
it uncovered in the debug coverage build.
@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot Please refresh this PR branch against current main, preserving your MiniJinja 3 migration commits, and bring in the Windows-only dirs fix from merged #4465 so current CI can pass. Run the focused checks for the resulting diff and report any conflict that requires a semantic or product decision.

The outstanding maintainer decision on MiniJinja 3 template behavior remains pending.

This was written by Codex on behalf of max-sixty

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

I merged current main into the branch as 7250f35c0. The merge had no conflicts and the MiniJinja 3 commits are preserved. Main now includes #4465, so dirs is a Windows-only dependency here too. Every check at that head is green, including check-unused-dependencies and codecov/patch.

Compared with main, the PR's diff is still only the migration (Cargo.toml/Cargo.lock, src/config/expansion.rs, src/config/template_analysis.rs). Nothing that came in from main needed a semantic or product decision.

I also ran some focused checks locally. cargo clippy --all-targets -D warnings is clean. The template, alias, and hook integration tests pass (406), and so does test_docs_are_in_sync. Lib tests had 1584 passing and 2 failing. Both failures are from the sandbox refusing to bind Unix sockets (Address family not supported by protocol), and CI ran both tests and they passed.

The decision on MiniJinja 3's Jinja2-aligned template behavior is still open for you.

@max-sixty
max-sixty merged commit dba1c64 into main Oct 14, 2026
42 checks passed
@max-sixty
max-sixty deleted the dependabot/cargo/minijinja-3.0.0 branch October 14, 2026 16:46
max-sixty added a commit that referenced this pull request Oct 20, 2026
Since the minijinja 3 upgrade in #4442, `{{ vars.cfg }}` renders a JSON
object or array var in Python style (`{'port': 3000}`) where v0.80.0
rendered JSON, and `{{ vars.cfg | tojson }}` fails with "unknown filter"
because minijinja's `json` feature was off. Since #3129 removed JSON on
hook stdin, templates are how hooks get structured values, so they had
no way to pass one to `jq` or `curl -d`.

This enables the `json` feature and documents `tojson` beside the vars
dot-access example in `wt hook --help`. `tojson` writes `'`, `<`, `>`
and `&` inside strings as `\u` escapes, which JSON parsers decode; the
shell formatter still single-quotes the result, so `-d {{ vars.config |
tojson }}` passes one argument.

Two adjustments come with the feature. It makes minijinja choose JSON
autoescaping from a template name ending in `.json`, `.js`, `.yaml` or
`.yml`, as it already did HTML escaping for `.html`. Worktrunk's
template names are config keys, so a custom column named `json` would
have rendered JSON-quoted cells, and one named `html` already rendered
HTML-escaped cells; the shared template environment now turns name-based
autoescaping off. minijinja's `tojson` also writes an undefined value as
`null`, so a wrapper rejects it the way printing does, and a mistyped
`vars` key errors instead of sending `null`.

Verified by rerunning the release-review repro against the branch
binary: `{{ vars.cfg | tojson }}` now renders `{"list": [1, 2], "port":
3000}`, and a custom column named `json` or `html` renders the raw
value. New coverage: a doc-template test for the documented `curl`
example in POSIX mode, a missing-key `tojson` error case, and the
custom-column test now uses a header named `json`. Each of the three
fails with its part of the change reverted.

Bare `{{ vars.cfg }}` still renders Python-style; `tojson` is the
supported way to get JSON.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants