Files
velero/pkg/restore/actions
Kaizhe HuangandGitHub 0f54eefe6f
e2e-test-kind.yaml / extract (push) Failing after 9s
Run the E2E test on kind / get-go-version (push) Failing after 10s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Failing after 3s
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 6s
Main CI / Build (push) Skipped
Scorecard supply-chain security / Scorecard analysis (push) Skipped
Fix unchecked type assertion panic in ChangeImageNameAction (#10574)
* Fix unchecked type assertion panic in ChangeImageNameAction

replaceImageName reads a restored container's image field out of the
unstructured object and asserts it to string without checking ok. The
comma-ok map lookup on the line above only confirms the "image" key is
present -- it says nothing about the value's type. A restored resource
whose image field is present but not a JSON string (e.g. a number,
bool, null, array, or object) causes an unrecovered
"interface conversion: interface {} is not string" panic in this
RestoreItemAction plugin whenever the optional image-remapping
ConfigMap feature is configured.

Switch to the comma-ok form of the assertion and skip (with a log
message) any container whose image field isn't a string, instead of
panicking.

Signed-off-by: Kaizhe Huang <derek0405@gmail.com>

* Add regression test for non-string image field panic

Covers the comma-ok assertion fix: replaceImageName operates on
generic unstructured content decoded from a backup tarball, which
isn't validated against the Pod schema before this code runs, so
"image" isn't guaranteed to be a string.

Signed-off-by: Kaizhe Huang <derek0405@gmail.com>

* Guard container-entry type assertion, use unstructured.NestedString

Addresses reviewer feedback: container.(map[string]any) was also an
unchecked assertion, and unstructured.NestedString gives safer,
more idiomatic type-checking than a manual comma-ok assertion. Also
switches the skip-path logging from Info to Warn per review.

Signed-off-by: Kaizhe Huang <derek0405@gmail.com>

---------

Signed-off-by: Kaizhe Huang <derek0405@gmail.com>
2026-09-28 15:29:50 +08:00
..
2024-04-10 14:53:29 +08:00
2024-04-10 14:53:29 +08:00