Skip to content

CNF-23579: Replace panics with error returns in production code - #1203

Open
sebrandon1 wants to merge 1 commit into
ComplianceAsCode:masterfrom
sebrandon1:replace-panics-with-errors
Open

CNF-23579: Replace panics with error returns in production code#1203
sebrandon1 wants to merge 1 commit into
ComplianceAsCode:masterfrom
sebrandon1:replace-panics-with-errors

Conversation

@sebrandon1

Copy link
Copy Markdown

Summary

  • Replace 4 panic() calls in non-test production code with proper error handling
  • saveScanResult in cel-scanner.go now returns error; caller logs and exits with CelExitCodeError
  • GetScanType and GetScannerType now return (T, error) instead of panicking
  • getTargetNodes in scantype.go propagates the error from GetScanType

Test plan

  • go build ./... passes
  • go vet ./... passes
  • Unit tests pass for pkg/apis/compliance/v1alpha1 and pkg/controller/compliancescan

@openshift-ci
openshift-ci Bot requested review from jhrozek and yuumasato May 6, 2026 18:32
@openshift-ci

openshift-ci Bot commented May 6, 2026

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 kubernetes-sigs/prow repository.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1203-d5b1ea8dc5161e7d122a0de30e2aeccadf6a6ca8

@sebrandon1 sebrandon1 changed the title Replace panics with error returns in production code CNF-23579: Replace panics with error returns in production code May 6, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Collaborator

@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.

Details

In response to this:

Summary

  • Replace 4 panic() calls in non-test production code with proper error handling
  • saveScanResult in cel-scanner.go now returns error; caller logs and exits with CelExitCodeError
  • GetScanType and GetScannerType now return (T, error) instead of panicking
  • getTargetNodes in scantype.go propagates the error from GetScanType

Test plan

  • go build ./... passes
  • go vet ./... passes
  • Unit tests pass for pkg/apis/compliance/v1alpha1 and pkg/controller/compliancescan

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.

@yuumasato

Copy link
Copy Markdown
Member

/ok-to-test

@sebrandon1
sebrandon1 force-pushed the replace-panics-with-errors branch from d5b1ea8 to dfdc2dc Compare July 6, 2026 16:16
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1203-dfdc2dcdc707fafd45e2407b2247f78bbdb6ce79

@sebrandon1
sebrandon1 force-pushed the replace-panics-with-errors branch from dfdc2dc to 9dfce3a Compare August 5, 2026 19:44
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign jhrozek for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1203-9d0f033610f2deaac6ac14eeceeba8dccb5a10a6

@sebrandon1
sebrandon1 force-pushed the replace-panics-with-errors branch 3 times, most recently from 53f330c to 39de06f Compare August 13, 2026 15:23
@github-actions

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1203-39de06f944f1436074ab43e50f6dd2a7f6b78aaa

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.
@sebrandon1
sebrandon1 force-pushed the replace-panics-with-errors branch from f155567 to baeaba2 Compare August 26, 2026 18:33
@openshift-ci

openshift-ci Bot commented Aug 26, 2026

Copy link
Copy Markdown

@sebrandon1: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-config d5b1ea8 link true /test e2e-aws-config
ci/prow/e2e-aws-parallel-arm d5b1ea8 link true /test e2e-aws-parallel-arm
ci/prow/e2e-rosa d5b1ea8 link true /test e2e-rosa
ci/prow/e2e-aws-scan-config d5b1ea8 link true /test e2e-aws-scan-config
ci/prow/e2e-aws-serial-arm d5b1ea8 link true /test e2e-aws-serial-arm
ci/prow/e2e-aws-deployment d5b1ea8 link true /test e2e-aws-deployment
ci/prow/unit baeaba2 link true /test unit
ci/prow/e2e-aws-parallel baeaba2 link true /test e2e-aws-parallel
ci/prow/images baeaba2 link true /test images
ci/prow/e2e-aws-serial baeaba2 link true /test e2e-aws-serial

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants