Wrap JSON parse errors in restoreInputs with context

This commit is contained in:
Michael B. Gale
2026-09-22 18:41:31 +01:00
parent f042742baf
commit a5c2338ec0
2 changed files with 20 additions and 8 deletions

13
lib/entry-points.js generated
View File

@@ -146389,11 +146389,16 @@ var persistInputs = function(env = getEnv()) {
core3.saveState(persistedInputsKey, JSON.stringify(inputEnvironmentVariables));
};
var restoreInputs = function() {
const persistedInputs = core3.getState(persistedInputsKey);
if (persistedInputs) {
for (const [name, value] of JSON.parse(persistedInputs)) {
process.env[name] = value;
try {
const persistedInputsValue = core3.getState(persistedInputsKey);
const persistedInputs = JSON.parse(persistedInputsValue);
if (persistedInputs) {
for (const [name, value] of persistedInputs) {
process.env[name] = value;
}
}
} catch (err) {
throw new Error(`Unable to restore inputs: ${getErrorMessage(err)}`);
}
};
function getPullRequestBranches(env = getEnv()) {

View File

@@ -14,6 +14,7 @@ import {
getCodeQLDatabasePath,
ConfigurationError,
getEnv,
getErrorMessage,
} from "./util";
/**
@@ -413,11 +414,17 @@ export const persistInputs = function (env: Env = getEnv()) {
* Restores all inputs to the action from the persisted state.
*/
export const restoreInputs = function () {
const persistedInputs = core.getState(persistedInputsKey);
if (persistedInputs) {
for (const [name, value] of JSON.parse(persistedInputs)) {
process.env[name] = value;
try {
const persistedInputsValue = core.getState(persistedInputsKey);
const persistedInputs = JSON.parse(persistedInputsValue);
if (persistedInputs) {
for (const [name, value] of persistedInputs) {
process.env[name] = value;
}
}
} catch (err) {
throw new Error(`Unable to restore inputs: ${getErrorMessage(err)}`);
}
};