Skip to content

fix(templates): use sha256 for hash filter instead of blake3#7925

Merged
jdx merged 2 commits intomainfrom
fix/hash-filter-sha256
Jan 31, 2026
Merged

fix(templates): use sha256 for hash filter instead of blake3#7925
jdx merged 2 commits intomainfrom
fix/hash-filter-sha256

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 31, 2026

Summary

  • Fix the hash template filter to use SHA256 instead of BLAKE3
  • The documentation 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 #7774

Test plan

  • Updated unit test to expect SHA256 output
  • cargo test test_hash passes

🤖 Generated with Claude Code


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.

Written by Cursor Bugbot for commit 7f5984d. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings January 31, 2026 13:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_str to hash_sha256_to_str in 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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 hash template filter was generating BLAKE3 hashes despite being documented to produce SHA256. The change updates the underlying hashing mechanism to use SHA256, ensuring the feature behaves as advertised and providing accurate cryptographic output.

Highlights

  • Hashing Algorithm Correction: The hash template filter now correctly uses SHA256, aligning with documentation, instead of the previously implemented BLAKE3 algorithm.
  • Unit Test Update: The test_hash unit test has been updated to verify the expected SHA256 output, ensuring the fix is validated.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

@jdx jdx force-pushed the fix/hash-filter-sha256 branch from 8703bfa to 9242da8 Compare January 31, 2026 13:58
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>
@jdx jdx force-pushed the fix/hash-filter-sha256 branch from 9242da8 to f31b899 Compare January 31, 2026 14:07
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>
@jdx jdx merged commit 6b4bb0a into main Jan 31, 2026
36 checks passed
@jdx jdx deleted the fix/hash-filter-sha256 branch January 31, 2026 14:36
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

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%

mise-en-dev added a commit that referenced this pull request Feb 1, 2026
### 🚀 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)
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
## 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>
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
### 🚀 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)
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.

2 participants