Skip to content

fix incorrect error handling in route53 dns provider#8167

Closed
Peac36 wants to merge 1 commit intocert-manager:masterfrom
Peac36:fix/route53-error-chain
Closed

fix incorrect error handling in route53 dns provider#8167
Peac36 wants to merge 1 commit intocert-manager:masterfrom
Peac36:fix/route53-error-chain

Conversation

@Peac36
Copy link
Copy Markdown
Contributor

@Peac36 Peac36 commented Oct 11, 2025

Pull Request Motivation

Fixes: #8166

/bug

NONE

CyberArk tracker: VC-46126

@cert-manager-prow cert-manager-prow bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/acme Indicates a PR directly modifies the ACME Issuer code area/acme/dns01 Indicates a PR modifies ACME DNS01 provider code needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 11, 2025
@cert-manager-prow
Copy link
Copy Markdown
Contributor

Hi @Peac36. Thanks for your PR.

I'm waiting for a cert-manager 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.

@cert-manager-prow cert-manager-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 11, 2025
@erikgb erikgb requested a review from Copilot October 11, 2025 18:24
@erikgb
Copy link
Copy Markdown
Member

erikgb commented Oct 11, 2025

/ok-to-test

@cert-manager-prow cert-manager-prow bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 11, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes incorrect error handling in the Route53 DNS provider by refactoring the error redaction mechanism to properly preserve error chains while removing sensitive request IDs from AWS error messages.

  • Replaced the problematic removeReqID function with a new RedactedError wrapper type
  • Updated error formatting to use %w verb instead of %s to maintain error wrapping
  • Renamed test function to reflect the new error handling approach

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/issuer/acme/dns/route53/route53.go Replaced removeReqID function with RedactedError type and updated error formatting
pkg/issuer/acme/dns/route53/route53_test.go Updated test function name and call to use new error handling function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Peac36 Peac36 force-pushed the fix/route53-error-chain branch from b7b9288 to 8be9473 Compare October 12, 2025 11:20
Signed-off-by: Nikola <peac36@abv.bg>
@Peac36 Peac36 force-pushed the fix/route53-error-chain branch from 8be9473 to f87cf45 Compare October 12, 2025 14:26
@cert-manager-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign munnerz 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

@erikgb erikgb requested a review from Copilot October 13, 2025 06:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +384 to +395
func (e *RedactedError) Error() string {
errString := e.Err.Error()
var responseError *awshttp.ResponseError
if errors.As(err, &responseError) {
if errors.As(e.Err, &responseError) {
before := responseError.Error()
// remove the request id from the error message
responseError.RequestID = "<REDACTED>"
after := responseError.Error()
return errors.New(strings.Replace(err.Error(), before, after, 1))
return strings.Replace(errString, before, after, 1)
}
return err
return errString
}
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Error() method modifies the original ResponseError by setting RequestID to '', which could affect other parts of the code that reference the same error. This is a side effect that violates the principle that Error() should be a read-only operation. Consider creating a copy of the ResponseError before modifying it.

Copilot uses AI. Check for mistakes.
Comment on lines +380 to +382
type RedactedError struct {
Err error
}
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RedactedError struct should validate that Err is not nil to prevent potential panics in the Error() and Unwrap() methods. Consider adding validation in a constructor function or checking for nil in the methods.

Copilot uses AI. Check for mistakes.
@erikgb
Copy link
Copy Markdown
Member

erikgb commented Oct 13, 2025

/cc @wallrj

I think you have been in route53-land before. 😅

@cert-manager-prow cert-manager-prow bot requested a review from wallrj October 13, 2025 06:54
@mladen-rusev-cyberark
Copy link
Copy Markdown

/cybr

@wallrj-cyberark wallrj-cyberark added the cybr Used by CyberArk-employed maintainers to report to line management what's being worked on. label Oct 15, 2025
@Peac36
Copy link
Copy Markdown
Contributor Author

Peac36 commented Oct 28, 2025

@wallrj-cyberark - did you have a chance to review the changes?

@wallrj-cyberark
Copy link
Copy Markdown
Member

@Peac36 I've been trying out a slightly different approach in #8221

I moved the redaction / stabilization code nearer to where it is required and use it only where it is required (for the Reason field), so that the full detailed errors are once again included in the Kubernetes Events which are attached to the Challenge resources.

@Peac36
Copy link
Copy Markdown
Contributor Author

Peac36 commented Nov 1, 2025

Closing in favor of #8221

@Peac36 Peac36 closed this Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/acme/dns01 Indicates a PR modifies ACME DNS01 provider code area/acme Indicates a PR directly modifies the ACME Issuer code cybr Used by CyberArk-employed maintainers to report to line management what's being worked on. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. ok-to-test release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS Route 53 dns provider error handling is inconsistent

5 participants