Skip to content

Commit b872fa3

Browse files
committed
fix: treat pvtr exit code 1 as success and truncate error output
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 573ed2c commit b872fa3

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • services/apps/security_best_practices_worker/src/activities

services/apps/security_best_practices_worker/src/activities/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,18 @@ async function runBinary(
221221
})
222222

223223
proc.on('close', (code) => {
224-
if (code === 0) {
225-
svc.log.info(`Binary completed successfully`)
224+
// exit code 0 = all tests passed, 1 = some tests failed — both mean the
225+
// evaluation ran to completion and wrote its output file
226+
if (code === 0 || code === 1) {
227+
svc.log.info(`Binary completed with exit code ${code}`)
226228
resolve({ stdout, stderr })
227229
} else {
228-
reject(new Error(`Binary exited with code ${code}\nStderr:\n${stderr}Stdout:\n${stdout}`))
230+
const truncated = (s: string) => (s.length > 500 ? s.slice(0, 500) + '…' : s)
231+
reject(
232+
new Error(
233+
`Binary exited with code ${code}\nStderr:\n${truncated(stderr)}Stdout:\n${truncated(stdout)}`,
234+
),
235+
)
229236
}
230237
})
231238
})

0 commit comments

Comments
 (0)