This repository was archived by the owner on Sep 11, 2025. It is now read-only.
feat: Add support for passing in environment variables to the WASM module#831
Merged
mattjohnsonpint merged 2 commits intomainfrom Apr 29, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for passing environment variables prefixed with "MODUS_" to the WASM module by stripping the prefix before forwarding them.
- Iterates through os.Environ() to extract MODUS_* environment variables
- Updates the WASM module configuration with the filtered environment variables
Comments suppressed due to low confidence (1)
runtime/wasmhost/wasmhost.go:140
- Consider adding unit tests to verify that environment variables prefixed with 'MODUS_' are correctly processed and stripped before being passed to the WASM module.
for _, env := range os.Environ() {
mattjohnsonpint
approved these changes
Apr 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We do not yet have a way to pass in environment variables to the WASM module running the app. That is possible only for variables used in a Modus connection, where you could pass variables with the format
MODUS_<CONNECTION NAME>_<KEY>, but within the app code users write, that is not accessible, as it's only accessible on the Runtime, and not passed down to the WASM module.This PR improves this by passing in all environment variables prefixed with
MODUS_to the WASM module, so that the Modus app code can read it. Note that theMODUS_prefix will be stripped before being passed in.This also implies that if you have a connection secret
MODUS_DGRAPH_API_KEYfor example, then that would be passed to the WASM module asDGRAPH_API_KEY.Checklist
All PRs should check the following boxes:
Conventional Commits syntax, leading with
fix:,feat:,chore:,ci:, etc.the contributing guide.
If the PR includes a code change, then also check the following boxes. (If not, then delete the
next section.)
CHANGELOG.mdfile.