Skip to content

fix: add condition for getrandom dependency#504

Merged
Pr0methean merged 5 commits intozip-rs:masterfrom
Its-Just-Nans:get-random-crate
Jan 12, 2026
Merged

fix: add condition for getrandom dependency#504
Pr0methean merged 5 commits intozip-rs:masterfrom
Its-Just-Nans:get-random-crate

Conversation

@Its-Just-Nans
Copy link
Member

Should fix #336 no?

Should I change the CI to run the wasm-pack tests?

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Its-Just-Nans, 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 enhances the zip crate's compatibility with WebAssembly by making the getrandom dependency conditional on the target architecture and introducing a new testing suite specifically for WASM environments. These changes address a reported issue related to getrandom in WASM and establish a robust testing framework for future WASM-related developments.

Highlights

  • getrandom dependency management: The getrandom crate dependency has been refactored to be target-specific, ensuring correct feature flags (std for native, wasm_js and std for wasm32) are used based on the compilation target.
  • WebAssembly (WASM) testing: Introduced a new test file tests/wasm32.rs and integrated wasm-bindgen-test to enable dedicated testing for WASM targets, including a test for AES256 encrypted zip files.
  • Dependency cleanup: The Cargo.toml file has been cleaned up by removing redundant getrandom entries from general and dev dependencies, consolidating its definition under target-specific sections.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 aims to fix an issue with aes-crypto on wasm32 targets by adjusting the getrandom dependency features. It introduces target-specific dependencies for getrandom in Cargo.toml and adds a new wasm32 test file.

My review focuses on the correctness of the dependency configuration and the new test code. I've found a critical issue in Cargo.toml regarding the getrandom version and feature flags which will prevent the wasm build from succeeding. I've also suggested improvements in the new test file to remove unused imports and reduce code duplication. Overall, the approach is correct, but these changes are needed to make it work and improve maintainability.

@Its-Just-Nans Its-Just-Nans marked this pull request as ready for review January 11, 2026 22:59
@Its-Just-Nans
Copy link
Member Author

Its-Just-Nans commented Jan 11, 2026

@Its-Just-Nans
Copy link
Member Author

rustversion 1.0.0
wasm-bindgen 0.2.100
js-sys 0.3.77

@Pr0methean
Copy link
Member

Pr0methean commented Jan 12, 2026

Looks good in principle, but this build error needs fixing:

error[E0433]: failed to resolve: could not find `cfg` in `rustversion`
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wasm-bindgen-0.2.106/build.rs:24:21
   |
24 |     if rustversion::cfg!(since(1.78)) {
   |                     ^^^ could not find `cfg` in `rustversion`

error[E0433]: failed to resolve: could not find `cfg` in `rustversion`
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wasm-bindgen-0.2.106/build.rs:39:29
   |
39 |             && rustversion::cfg!(all(since(1.82), before(1.84))))
   |                             ^^^ could not find `cfg` in `rustversion`

Maybe we need a newer version of the rustversion crate? From bisecting on docs.rs, it looks like the cfg macro was added in 1.0.6.

@Its-Just-Nans
Copy link
Member Author

Maybe we need a newer version of the rustversion crate?

Yes exactly but the rustversion is a dependency of a dependency

@Its-Just-Nans Its-Just-Nans changed the title change getrandom deps fix: add condition for getrandom dependency Jan 12, 2026
@Pr0methean Pr0methean enabled auto-merge January 12, 2026 03:53
@Its-Just-Nans
Copy link
Member Author

Its-Just-Nans commented Jan 12, 2026

@Pr0methean

Maybe we could wait for an answer wasm-bindgen/wasm-bindgen#4899

EDIT:

The merge of wasm-bindgen/wasm-bindgen#4899 will not help today since we depends on wasm-bindgen@0.2.100 but maybe in the future when our dependencies will use ^0.2.106

@Pr0methean Pr0methean added this to the 7.1.0 milestone Jan 12, 2026
@Pr0methean
Copy link
Member

@Pr0methean

Maybe we could wait for an answer wasm-bindgen/wasm-bindgen#4899

EDIT:

The merge of wasm-bindgen/wasm-bindgen#4899 will not help today since we depends on wasm-bindgen@0.2.100 but maybe in the future when our dependencies will use ^0.2.106

Well, the build error has disappeared one way or another, which is good enough for me for at least zip 7.1.0.

@Its-Just-Nans
Copy link
Member Author

Well, the build error has disappeared one way or another, which is good enough for me for at least zip 7.1.0.

Okay I will do a tracking issue if this MR is merged

btw, should I add wasm-pack tests in CI?

@Pr0methean Pr0methean disabled auto-merge January 12, 2026 18:41
@Pr0methean Pr0methean merged commit 19664c6 into zip-rs:master Jan 12, 2026
104 checks passed
@Pr0methean Pr0methean mentioned this pull request Jan 12, 2026
@Pr0methean Pr0methean mentioned this pull request Jan 14, 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.

Unconditional use of getrandom’s wasm_js feature is counter to upstream guidance

2 participants