fix: pass cwd to all exec calls in exportMiseEnv() - #390
Conversation
Greptile SummaryThis PR fixes Key changes:
One pre-existing security best-practice issue was identified: the actual (unredacted) values call should also use Confidence Score: 4/5
Last reviewed commit: eacf433 |
Summary of ChangesHello, 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 a significant bug in the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request addresses a bug where exportMiseEnv() ignored the working_directory, causing mise commands to execute in an incorrect directory. The fix correctly determines the working directory and passes it to all external process calls within the function. The change is logical and directly solves the described problem. I have one suggestion regarding code duplication to improve long-term maintainability.
| const cwd = | ||
| core.getInput('working_directory') || | ||
| core.getInput('install_dir') || | ||
| process.cwd() |
There was a problem hiding this comment.
This logic for determining the cwd is also present in the mise helper function (starting on line 353). To improve maintainability and avoid code duplication, consider extracting this logic into a shared helper function. For example:
function getMiseCwd(): string {
return (
core.getInput('working_directory') ||
core.getInput('install_dir') ||
process.cwd()
);
}This new function could then be called here and in the mise helper function to ensure consistency and a single source of truth for this logic.
| const actualOutput = await exec.getExecOutput('mise', ['env', '--json'], { | ||
| cwd | ||
| }) |
There was a problem hiding this comment.
The call to mise env --json that retrieves actual (unredacted) environment variable values does not set silent: true. This means the real secret values will appear in the GitHub Actions log output, even though masking is applied after.
The preceding mise env --redacted --json call correctly uses { silent: true } to avoid exposing values in logs. The same option should be applied here to prevent logging sensitive data:
| const actualOutput = await exec.getExecOutput('mise', ['env', '--json'], { | |
| cwd | |
| }) | |
| const actualOutput = await exec.getExecOutput('mise', ['env', '--json'], { | |
| cwd, | |
| silent: true | |
| }) |
While GitHub Actions' masking should catch these values, the safest approach is to never log them at all.
There was a problem hiding this comment.
double check my thinking here @andrewthauer but I think we don't want to set silent. I think we want to rely on the redactions working. If we didn't do that, it would hide any errors from mise making debugging hard.
There was a problem hiding this comment.
I agree with your reasoning. Not setting silent: true on the actual mise env --json call is the right approach here because:
- Errors need to be visible - If mise fails (e.g., lockfile issues, network problems, config errors), those error messages are critical for debugging and won't contain secrets
- Redaction mechanism should work - You're already calling
mise env --redacted --jsonfirst and registering all the keys withcore.setSecret(), so the actual values should be masked when they appear in logs - The pattern is correct - First call (redacted, silent) → register masks → second call (actual, visible but masked) is the right sequence
The only outputs that would appear in logs from the non-silent call are:
- Error messages (which you need to see)
- Success output (which should be fully masked by the prior
setSecret()calls)
Setting silent: true would hide mise errors and make CI failures much harder to diagnose, especially for the exact lockfile/network issues you're fixing in this PR.
--- ## [3.6.3](https://github.com/jdx/mise-action/compare/v3.6.2..v3.6.3) - 2026-03-06 ### 🐛 Bug Fixes - pass cwd to all exec calls in exportMiseEnv() (#390) by [@andrewthauer](https://github.com/andrewthauer) in [#390](#390) ### New Contributors * @andrewthauer made their first contribution in [#390](#390) <!-- generated by git-cliff -->
Problem
The
exportMiseEnv()function ignores theworking_directory(andinstall_dir) input when runningmise env --json. It always executes in the process default CWD — the GitHub Actions workspace root — regardless of what directory was used formise install.This means if a caller sets
working_directory: path/to/subdir, mise resolves environment variables against the workspace root'smise.toml, not the intended subdirectory's config.Impact
Since mise 2026.2.0, lockfiles are enabled by default. When
mise env --jsonruns without amise.lockpresent (e.g. because the correctworking_directorywas not used), mise attempts to resolve loose tool versions (like"latest") from the network. In environments with private npm registries, this causesnpm viewcalls that fail with 403 errors. Mise retries indefinitely, spawning 20+ orphaned npm processes and eventually hittingEAGAIN(OS error 11), hanging CI permanently.The other mise commands (
miseInstall,miseReshim, etc.) already passcwdcorrectly via the sharedmise()helper. OnlyexportMiseEnv()was missing this.Fix
Resolve
working_directory(falling back toinstall_dir, thenprocess.cwd()) at the top ofexportMiseEnv()and pass{ cwd }to all fourexec.getExecOutputcalls within the function:mise env --redacted --jsonmise env --jsonmise env --dotenv(redacted fallback)mise env --dotenv(legacy fallback)Related
working_directorynot considered when exporting environment variables #267:working_directorynot respected for env export