Skip to content

fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic - #14986

Merged
Legend-Master merged 2 commits into
tauri-apps:devfrom
montyc1999:fix-nondeterministic-csp-context
Feb 23, 2026
Merged

fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic#14986
Legend-Master merged 2 commits into
tauri-apps:devfrom
montyc1999:fix-nondeterministic-csp-context

Conversation

@montyc1999

Copy link
Copy Markdown
Contributor

Fixes #14978

It would be nicer to convert these HashMaps to BTreeMaps, but that would be a breaking change.

@github-actions

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 233138d

There are 4 changes which include tauri-cli with patch, @tauri-apps/cli with patch, tauri-utils with patch, tauri-bundler with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.2 2.8.3
tauri-bundler 2.8.0 2.8.1
tauri-runtime 2.10.0 2.10.1
tauri-runtime-wry 2.10.0 2.10.1
tauri-codegen 2.5.4 2.5.5
tauri-macros 2.5.4 2.5.5
tauri-plugin 2.5.3 2.5.4
tauri-build 2.5.5 2.5.6
tauri 2.10.2 2.10.3
@tauri-apps/cli 2.10.0 2.10.1
tauri-cli 2.10.0 2.10.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master

Copy link
Copy Markdown
Contributor

Nice catch, could you also add some comments about the reason for this and a todo about changing it them to BTreeMaps?

@montyc1999
montyc1999 force-pushed the fix-nondeterministic-csp-context branch from 40083ae to 233138d Compare February 23, 2026 13:16
@montyc1999

Copy link
Copy Markdown
Contributor Author

@Legend-Master sure, added. How's that?

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@Legend-Master
Legend-Master merged commit 7b16daf into tauri-apps:dev Feb 23, 2026
26 checks passed
chippers pushed a commit to chippers/tauri that referenced this pull request Mar 3, 2026
…o `generate_context!` is deterministic (tauri-apps#14986)

* fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic

* add comments explaining rationale, and todo for removing the hack in v3
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
…o `generate_context!` is deterministic (tauri-apps#14986)

* fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic

* add comments explaining rationale, and todo for removing the hack in v3
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
…o `generate_context!` is deterministic (tauri-apps#14986)

* fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic

* add comments explaining rationale, and todo for removing the hack in v3
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
…o `generate_context!` is deterministic (tauri-apps#14986)

* fix(tauri-utils): sort csp/plugin/header config maps during codegen so generate_context! is deterministic

* add comments explaining rationale, and todo for removing the hack in v3
VityaSchel added a commit to VityaSchel/tauri that referenced this pull request Jul 25, 2026
generate_context! emitted the embedded asset map and the CSP script/style
hashes in filesystem walk order (varies across machines) and HashMap
iteration order (varies per process), and serializing the processed config
wrote the csp/headers/plugins maps in HashMap iteration order. Both broke
reproducible builds: the same source built on two machines produced
different binaries and a different tauri.conf.json in the generated
Android project. Iterate all of them sorted, complementing tauri-apps#14986 which
sorted the same config maps on the ToTokens path.

closes tauri-apps#14978
Legend-Master added a commit that referenced this pull request Aug 5, 2026
…tic (#15777)

* fix: make embedded assets codegen and config serialization deterministic

generate_context! emitted the embedded asset map and the CSP script/style
hashes in filesystem walk order (varies across machines) and HashMap
iteration order (varies per process), and serializing the processed config
wrote the csp/headers/plugins maps in HashMap iteration order. Both broke
reproducible builds: the same source built on two machines produced
different binaries and a different tauri.conf.json in the generated
Android project. Iterate all of them sorted, complementing #14986 which
sorted the same config maps on the ToTokens path.

closes #14978

* Use `BTreeMap` for embedded assets and inline script hashes

* remove outdated comment

* Convert to BTreeMap instead of sort to vec

---------

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
Co-authored-by: Tony <legendmastertony@gmail.com>
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.

[bug] generate_context! macro doesn't sort CSP object keys, breaks incremental cache

2 participants