CNF-23579: Replace panics with error returns in production code#1203
CNF-23579: Replace panics with error returns in production code#1203sebrandon1 wants to merge 1 commit into
Conversation
Four panic() calls in non-test code crash the process for recoverable errors. Replace them with proper error handling: - cel-scanner.go: saveScanResult now returns error; caller logs and exits with CelExitCodeError, matching every other error path in runPlatformScan. - compliancescan_types.go: GetScanType and GetScannerType now return (T, error) instead of panicking, delegating to the IfValid variants. - scantype.go: getTargetNodes propagates the error from GetScanType.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sebrandon1 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @sebrandon1. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
🤖 To deploy this PR, run the following command: |
|
@sebrandon1: This pull request references CNF-23579 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Summary
panic()calls in non-test production code with proper error handlingsaveScanResultin cel-scanner.go now returnserror; caller logs and exits withCelExitCodeErrorGetScanTypeandGetScannerTypenow return(T, error)instead of panickinggetTargetNodesin scantype.go propagates the error fromGetScanTypeTest plan
go build ./...passesgo vet ./...passespkg/apis/compliance/v1alpha1andpkg/controller/compliancescan