fix: set outputs/env vars for empty string field values

Empty string field values from 1Password were causing the action to skip setting outputs and environment variables entirely.
This was inconsistent with `op run` behavior, which sets the variable with an empty value.

- Change falsy check to explicit null/undefined check in extractSecret
- Skip setSecret for empty strings to avoid runner warning
- Add tests for empty string value handling
This commit is contained in:
toga4
2026-01-23 10:30:58 +09:00
parent fdb192f5dc
commit 13f927c806
2 changed files with 41 additions and 2 deletions

View File

@@ -41,7 +41,7 @@ export const extractSecret = (
}
const secretValue = read.parse(ref);
if (!secretValue) {
if (secretValue === null || secretValue === undefined) {
return;
}
@@ -50,7 +50,11 @@ export const extractSecret = (
} else {
core.setOutput(envName, secretValue);
}
core.setSecret(secretValue);
// Skip setSecret for empty strings to avoid the warning:
// "Can't add secret mask for empty string in ##[add-mask] command."
if (secretValue) {
core.setSecret(secretValue);
}
};
export const loadSecrets = async (shouldExportEnv: boolean): Promise<void> => {