fix(templates): use sha256 for hash filter instead of blake3#7925
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the hash template filter to use SHA256 instead of BLAKE3, aligning the implementation with the documentation.
Changes:
- Changed the hash function from
hash_blake3_to_strtohash_sha256_to_strin the filter implementation - Updated the unit test to verify SHA256 output instead of BLAKE3
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary of ChangesHello @jdx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an inconsistency where the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes the hash template filter to use SHA256 as documented, instead of BLAKE3. The change is straightforward and the unit test has been updated accordingly. I have one suggestion to also update the hash_file filter to use SHA256 for consistency, as it currently still uses BLAKE3.
src/tera.rs
Outdated
| move |input: &Value, args: &HashMap<String, Value>| match input { | ||
| Value::String(s) => { | ||
| let mut hash = hash::hash_blake3_to_str(s); | ||
| let mut hash = hash::hash_sha256_to_str(s); |
There was a problem hiding this comment.
This change correctly aligns the hash filter with its documentation. For consistency, consider also updating the hash_file filter, which is defined nearby, to use SHA256. It currently uses hash::file_hash_blake3.
A corresponding function hash::file_hash_sha256 already exists. This would ensure both hashing filters behave consistently for users, though it would be a breaking change for hash_file and require updating its test snapshot.
8703bfa to
9242da8
Compare
The documentation states the hash filter produces SHA256, but the
implementation was using BLAKE3. This fixes the implementation to
match the documented behavior.
Added an `algorithm` parameter to allow choosing between sha256 (default)
and blake3:
- `{{ "foo" | hash }}` - uses sha256 (default)
- `{{ "foo" | hash(algorithm="sha256") }}` - explicitly use sha256
- `{{ "foo" | hash(algorithm="blake3") }}` - use blake3
Fixes #7774
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9242da8 to
f31b899
Compare
Wrap template examples in v-pre spans to prevent Vue from interpreting them as Vue template expressions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.12 x -- echo |
16.0 ± 0.4 | 14.9 | 17.2 | 1.00 |
mise x -- echo |
16.4 ± 0.5 | 15.1 | 18.2 | 1.03 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.12 env |
15.5 ± 0.4 | 14.6 | 16.5 | 1.00 |
mise env |
16.2 ± 0.7 | 14.9 | 23.9 | 1.04 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.12 hook-env |
16.0 ± 0.5 | 14.7 | 20.7 | 1.00 |
mise hook-env |
16.2 ± 0.5 | 15.3 | 20.3 | 1.01 ± 0.04 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.12 ls |
14.5 ± 0.4 | 13.6 | 15.6 | 1.00 |
mise ls |
15.2 ± 0.5 | 14.1 | 16.7 | 1.04 ± 0.04 |
xtasks/test/perf
| Command | mise-2026.1.12 | mise | Variance |
|---|---|---|---|
| install (cached) | 83ms | 85ms | -2% |
| ls (cached) | 55ms | 56ms | -1% |
| bin-paths (cached) | 58ms | 58ms | +0% |
| task-ls (cached) | 455ms | 466ms | -2% |
### 🚀 Features - **(edit)** add interactive config editor (`mise edit`) by @jdx in [#7930](#7930) - **(lockfile)** graduate lockfiles from experimental by @jdx in [#7929](#7929) - **(task)** add support for usage values in task confirm dialog by @roele in [#7924](#7924) - **(task)** improve source freshness checking with edge case handling by @jdx in [#7932](#7932) ### 🐛 Bug Fixes - **(activate)** preserve ordering of paths appended after mise activate by @jdx in [#7919](#7919) - **(install)** sort failed installations for deterministic error output by @jdx in [#7936](#7936) - **(lockfile)** preserve URL and prefer sha256 when merging platform info by @jdx in [#7923](#7923) - **(lockfile)** add atomic writes and cache invalidation by @jdx in [#7927](#7927) - **(templates)** use sha256 for hash filter instead of blake3 by @jdx in [#7925](#7925) - **(upgrade)** respect tracked configs when pruning old versions by @jdx in [#7926](#7926) ### 🚜 Refactor - **(progress)** migrate from indicatif to clx by @jdx in [#7928](#7928) ### 📚 Documentation - improve clarity on uvx and pipx dependencies by @ygormutti in [#7878](#7878) ### ⚡ Performance - **(install)** use Kahn's algorithm for dependency scheduling by @jdx in [#7933](#7933) - use Aho-Corasick for efficient redaction by @jdx in [#7931](#7931) ### 🧪 Testing - remove flaky test_http_version_list test by @jdx in [#7934](#7934) ### Chore - use github backend instead of ubi in mise.lock by @jdx in [#7922](#7922) ### New Contributors - @ygormutti made their first contribution in [#7878](#7878)
## Summary - Fix the `hash` template filter to use SHA256 instead of BLAKE3 - The [documentation](https://mise.jdx.dev/templates.html#hash) states the hash filter produces SHA256, but the implementation was using BLAKE3 ## Problem The `hash` filter was producing BLAKE3 hashes instead of the documented SHA256: ``` {{ "" | hash }} # Produced: af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 (BLAKE3) # Should be: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 (SHA256) ``` ## Solution Changed `hash::hash_blake3_to_str(s)` to `hash::hash_sha256_to_str(s)` in the filter implementation. Fixes jdx#7774 ## Test plan - [x] Updated unit test to expect SHA256 output - [x] `cargo test test_hash` passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the default output of the `hash` template filter from BLAKE3 to SHA256, which may affect existing templates relying on the previous hash value. Impact is limited to template rendering and includes test/doc updates. > > **Overview** > The `hash` Tera filter now defaults to **SHA256** instead of BLAKE3, and accepts an optional `algorithm` argument (`sha256` or `blake3`) with explicit erroring on unknown values. > > Docs for template hashing were updated to describe the new `hash` signature and include examples, and the `test_hash` unit test was updated to validate SHA256-by-default plus an explicit BLAKE3 option. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7f5984d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
### 🚀 Features - **(edit)** add interactive config editor (`mise edit`) by @jdx in [jdx#7930](jdx#7930) - **(lockfile)** graduate lockfiles from experimental by @jdx in [jdx#7929](jdx#7929) - **(task)** add support for usage values in task confirm dialog by @roele in [jdx#7924](jdx#7924) - **(task)** improve source freshness checking with edge case handling by @jdx in [jdx#7932](jdx#7932) ### 🐛 Bug Fixes - **(activate)** preserve ordering of paths appended after mise activate by @jdx in [jdx#7919](jdx#7919) - **(install)** sort failed installations for deterministic error output by @jdx in [jdx#7936](jdx#7936) - **(lockfile)** preserve URL and prefer sha256 when merging platform info by @jdx in [jdx#7923](jdx#7923) - **(lockfile)** add atomic writes and cache invalidation by @jdx in [jdx#7927](jdx#7927) - **(templates)** use sha256 for hash filter instead of blake3 by @jdx in [jdx#7925](jdx#7925) - **(upgrade)** respect tracked configs when pruning old versions by @jdx in [jdx#7926](jdx#7926) ### 🚜 Refactor - **(progress)** migrate from indicatif to clx by @jdx in [jdx#7928](jdx#7928) ### 📚 Documentation - improve clarity on uvx and pipx dependencies by @ygormutti in [jdx#7878](jdx#7878) ### ⚡ Performance - **(install)** use Kahn's algorithm for dependency scheduling by @jdx in [jdx#7933](jdx#7933) - use Aho-Corasick for efficient redaction by @jdx in [jdx#7931](jdx#7931) ### 🧪 Testing - remove flaky test_http_version_list test by @jdx in [jdx#7934](jdx#7934) ### Chore - use github backend instead of ubi in mise.lock by @jdx in [jdx#7922](jdx#7922) ### New Contributors - @ygormutti made their first contribution in [jdx#7878](jdx#7878)
Summary
hashtemplate filter to use SHA256 instead of BLAKE3Problem
The
hashfilter was producing BLAKE3 hashes instead of the documented SHA256:Solution
Changed
hash::hash_blake3_to_str(s)tohash::hash_sha256_to_str(s)in the filter implementation.Fixes #7774
Test plan
cargo test test_hashpasses🤖 Generated with Claude Code
Note
Medium Risk
Changes the default output of the
hashtemplate filter from BLAKE3 to SHA256, which may affect existing templates relying on the previous hash value. Impact is limited to template rendering and includes test/doc updates.Overview
The
hashTera filter now defaults to SHA256 instead of BLAKE3, and accepts an optionalalgorithmargument (sha256orblake3) with explicit erroring on unknown values.Docs for template hashing were updated to describe the new
hashsignature and include examples, and thetest_hashunit test was updated to validate SHA256-by-default plus an explicit BLAKE3 option.Written by Cursor Bugbot for commit 7f5984d. This will update automatically on new commits. Configure here.