Skip to content

Commit ca3ea6c

Browse files
Ensure we don't send strings in the error property (#1653)
Part of OPS-2843.
1 parent f4f34a5 commit ca3ea6c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/openops/src/lib/cloud-cli-common.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export function handleCliError({
1010
command: string;
1111
error: unknown;
1212
}): never {
13-
logger.error(`${provider} CLI execution failed.`, {
14-
command,
15-
error,
16-
});
13+
logger.error(
14+
`${provider} CLI execution failed.`,
15+
error instanceof Error
16+
? { command, error }
17+
: { command, errorMessage: error },
18+
);
1719

1820
const message = `An error occurred while running ${provider} CLI command: ${error}`;
1921

packages/openops/src/lib/command-wrapper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export async function executeFile(
4242

4343
async function getResult(childProcess: ChildProcess, fullCommand: string) {
4444
let stdout = '';
45-
let error = '';
45+
let errorMessage = '';
4646

4747
childProcess.stderr?.on('data', function (data) {
48-
error += data;
48+
errorMessage += data;
4949
});
5050

5151
childProcess.stdout?.on('data', (data) => {
@@ -62,13 +62,13 @@ async function getResult(childProcess: ChildProcess, fullCommand: string) {
6262
command: fullCommand,
6363
exitCode,
6464
stdout,
65-
error,
65+
errorMessage,
6666
});
6767

6868
return {
6969
exitCode: exitCode,
7070
stdOut: trimNewLines(stdout),
71-
stdError: trimNewLines(error),
71+
stdError: trimNewLines(errorMessage),
7272
};
7373
}
7474

0 commit comments

Comments
 (0)