Skip to content

fix: resolve AES-GCM Web Crypto interop failure in Pyodide worker#42

Closed
Shubhashish-Chakraborty wants to merge 3 commits into
alphaonelabs:mainfrom
Shubhashish-Chakraborty:aesgcm-fix
Closed

fix: resolve AES-GCM Web Crypto interop failure in Pyodide worker#42
Shubhashish-Chakraborty wants to merge 3 commits into
alphaonelabs:mainfrom
Shubhashish-Chakraborty:aesgcm-fix

Conversation

@Shubhashish-Chakraborty
Copy link
Copy Markdown
Contributor

@Shubhashish-Chakraborty Shubhashish-Chakraborty commented Apr 14, 2026

Problem

All encrypt_aes and decrypt_aes calls were failing with NotSupportedError: Unrecognized key import algorithm "undefined". This leads to user registration failure. Previously this issue was already addressed in #27 and PR was merged but after a further commit 8ac4409... , this reintroduced the AES bug.

image

Root Cause

In Pyodide, passing a bare Python dict to js.crypto.subtle APIs does not produce a plain JS object. Without an explicit converter, to_js({"name": "AES-GCM"}) produces a JS Map. The Web Crypto API reads algorithm parameters via dot-notation (e.g. algo.name), which returns undefined on a Map, and hence the error.

The previous correct fix used dict_converter=js.Object.fromEntries. Commit 8ac4409 removed that, leaving raw Python dicts and rebreaking everything.

FIx

Replaced all three algorithm parameter constructions in _import_aes_key, encrypt_aes, and decrypt_aes with js.Object.new() instances, setting .name and .iv as explicit JS properties.

Aditionally:

I've added _JsObject and _JsObjectClass stubs so that js.Object.new() works in the test environment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

@Shubhashish-Chakraborty has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 42 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 42 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 10e80309-5f94-4469-8f1c-2c72aae1548d

📥 Commits

Reviewing files that changed from the base of the PR and between 2b843c2 and 39c70e0.

📒 Files selected for processing (2)
  • src/worker.py
  • tests/conftest.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Shubhashish-Chakraborty Shubhashish-Chakraborty changed the title pass jsobject instead of python dict fix: resolve AESGCM Web Crypto interop failure in Pyodide worker Apr 14, 2026
@Shubhashish-Chakraborty Shubhashish-Chakraborty changed the title fix: resolve AESGCM Web Crypto interop failure in Pyodide worker fix: resolve AES-GCM Web Crypto interop failure in Pyodide worker Apr 14, 2026
@Shubhashish-Chakraborty
Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

✅ Actions performed

Reviews resumed.

@Shubhashish-Chakraborty
Copy link
Copy Markdown
Contributor Author

Fixed

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.

1 participant