`sanitizeSkopeoErrorForLogging` was unconditionally deleting `message`
from every error caught in `pullImages`. The original intent was to
avoid logging skopeo command lines (which contain
`--src-creds <user:pass>`), but the same scrubbing was applied to
non-skopeo failures such as ECR credential-resolution errors. That
produced log lines like "failed to pull image docker/oci archive image"
with no underlying cause, blocking root-cause analysis for IRSA / ECR
pull failures (Tessl AI hit this in v2.22.20).
Branch on the error shape instead:
- Skopeo `ChildProcessError`s (identified by a populated `stderr`):
drop `message` (creds), keep `stderr` (the real failure detail),
drop `childProcess` and `stack`.
- Every other error: keep `message`, drop `childProcess` (defensive)
and `stack`.
Also stop mutating the original error object, type the input as
`unknown`, and add unit tests covering both branches plus the
non-object / empty-stderr edge cases.
Refs: CN-1360, CN-1359
What this does
Fixes CN-1360 (parent CN-1359).
sanitizeSkopeoErrorForLogginginsrc/scanner/images/index.tsunconditionally deletesmessagefrom every error caught inpullImages. The intent was to scrub the skopeo command line, which embeds credentials passed via--src-creds <user:pass>. The side effect: non-skopeo errors (e.g. ECR credential-resolution failures under IRSA) also lose theirmessage, leaving only a useless log line:…with no actionable detail. Tessl AI hit this on v2.22.20.
This PR branches on the error shape:
ChildProcessErrors (identified by a populatedstderrfield) — dropmessage(creds), dropchildProcessandstack, keepstderr(the actual skopeo failure detail).stderr) — keepmessageso the underlying cause survives. Still dropchildProcessandstackdefensively.The helper now also returns a new object instead of mutating the input, and the
error: anyis replaced witherror: unknownplus narrowing.Notes for the reviewer
// Exported for testing) so unit tests can hit it directly.test/unit/scanner/images.spec.tscover both branches plus non-object / empty-stderr edge cases, and explicitly assert that--src-creds/ the secret value never appear in the sanitized output.pullImagesitself; only the contents of the loggederrorobject differ.Test plan
npm run lint:eslintcleannpm run test:unit— 312 tests pass (18 suites)--src-credsand the credential value are absent from the sanitized skopeo errormessageis preserved for non-skopeo errors (e.g. "ECR token fetch failed")