Skip to content

fix(util): reject CSV input that cannot be read back unchanged, round-trip a single empty value - #9157

Merged
cert-manager-prow[bot] merged 4 commits into
cert-manager:masterfrom
hamodywe:fix/util-csv-empty-crlf-roundtrip
Sep 3, 2026
Merged

cert-manager-prow[bot] merged 4 commits into
cert-manager:masterfrom
hamodywe:fix/util-csv-empty-crlf-roundtrip

Conversation

@hamodywe

@hamodywe hamodywe commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9147.

Reworked after @wallrj's review. The guard is unchanged in intent; it has moved to the layer where it cannot block issuance, and the rejection now sits on the parser rather than the writer.

The bug

JoinWithEscapeCSV/SplitWithEscapeCSV are the round trip that stores certificate subject fields as Secret annotations and reads them back for ingress-shim. The round-trip property test on #9149 found two counterexamples:

  1. [""] (a single empty value) joins to "" — an empty line — which SplitWithEscapeCSV then rejects with no values found after parsing "". encoding/csv writing one empty field is indistinguishable from zero records on read.
  2. A value containing "\r\n" comes back as "\n". encoding/csv's reader normalizes line endings inside a quoted field, so the value changes instead of erroring.

What changed since the previous revision

The previous revision rejected CRLF inside JoinWithEscapeCSV. As the review showed, that turned a previously-dead error path live at two call sites that cannot afford one:

  • AnnotationsForCertificate runs between signing and the Secret Apply, so a CA-signed certificate carrying a CRLF in a subject field wedged: revision never bumps, Issuing condition never clears, failedIssuanceAttempts never increments.
  • It runs again as the second link of the post-issuance policy chain, where an error short-circuits the checks that reconcile SecretTemplate metadata, keystores, additional output formats and owner references — and the consumer swallows the violation, so the Certificate stays Ready=True.

So the responsibilities are now split:

Function Behaviour
JoinWithEscapeCSV Total again. Still encodes a single empty value as ""; documents that the empty slice is deliberately exempt from the round trip, so nobody widens it later.
SplitWithEscapeCSV Rejects input it cannot read back unchanged. It is the only production parser, and the one fed user-authored Ingress/Gateway annotations.
AnnotationsForCertificate Drops the single offending annotation instead of discarding all twelve through a sticky error. Derived metadata, not payload.

AnnotationsForCertificate no longer returns an error — there is nothing left for it to fail on, and making that structural is a stronger statement than a comment. It costs one branch each at its two call sites (setValues, certificateDataAnnotationsForSecret); it is an internal/ function, so there is no downstream API surface. Happy to restore the (map, error) signature if you would rather keep the shape.

What SplitWithEscapeCSV rejects, exactly

Measured against encoding/csv directly, only two inputs are read back as something else:

Input encoding/csv returns Now
"line1\r\nline2" (quoted CRLF) line1\nline2 — rewritten rejected
line1\r (trailing CR) line1 — dropped rejected
line1\rline2 (CR elsewhere) line1\rline2 — unchanged accepted, unchanged
"line1\rline2" (quoted CR) line1\rline2 — unchanged accepted, unchanged

The title of the previous revision said "reject CR", which was wrong on both counts — a lone \r round-trips fine, and the rejection is no longer on the join side at all.

Known consequence, stated rather than hidden

Encoding a single empty value as "" changes a documented annotation value. For an existing Secret whose certificate has a single empty subject value, the mismatch check recomputes "" against the stored empty string and rewrites it once. That converges, but it bumps resourceVersion and wakes watchers, so it is in the release note.

The same value has one awkward edge that this PR does not change: cert-manager.io/alt-names: '""' copied by hand from a Secret onto an Ingress is no longer treated as empty by the altNames != "" guard in ingress-shim, because that path splits on commas rather than through SplitWithEscapeCSV. Reaching it needs a certificate with exactly one, empty, DNS name and a manual copy of the annotation. Happy to add the guard here if you would rather close it in the same PR.

Testing

New/changed:

  • TestSplitWithEscapeCSVRejectsInputItCannotReadBackUnchanged — the two lossy shapes above.
  • TestSplitWithEscapeCSVKeepsACarriageReturnItCanReadBack — pins the narrow rule, so widening the check back to every \r fails here.
  • Test_AnnotationsForCertificateSecret — a subject value containing a CRLF costs its own annotation and nothing else; a single empty subject value stores "".
  • TestJoinWithEscapeCSVRejectsCRLF is gone, since the join side no longer rejects.

TestJoinSplitWithEscapeCSVRoundTrip still overlaps the property test on #9149 as you noted; I have left it as the regression for the [""] case and am happy to drop it in favour of relaxing that test's Assume exclusions once both land.

Revert-checked: with the two guards removed, TestSplitWithEscapeCSVRejectsInputItCannotReadBackUnchanged fails on both cases and the CRLF annotation case reports the extra cert-manager.io/subject-organizations: "\"Example\r\nOrganization\"". With them in place:

go vet ./pkg/util/... ./internal/controller/certificates/... ./pkg/controller/certificates/... ./pkg/controller/certificate-shim/...   # clean
go test ./pkg/util/... ./internal/controller/certificates/... ./pkg/controller/certificates/... ./pkg/controller/certificate-shim/... # all ok

Release Notes

`SplitWithEscapeCSV` now rejects input that CSV parsing cannot read back unchanged — a CRLF inside a quoted field, or a trailing carriage return — instead of silently altering the value. A certificate subject value that cannot be encoded no longer fails issuance: only the affected Secret annotation is omitted. A certificate with a single empty subject value now stores that annotation as `""` instead of an empty string, so any existing Secret with one is rewritten once on upgrade.

…gle empty value, reject CR

JoinWithEscapeCSV and SplitWithEscapeCSV form a production round trip:
subject fields are joined into Secret annotations and ingress-shim splits
annotation values back into subject fields. Two counterexamples:

- []string{""} joins to the empty string, which SplitWithEscapeCSV then
  rejects with "no values found after parsing \"\"" - a single empty
  value cannot round-trip.
- A value containing "\r\n" comes back as "\n": encoding/csv's reader
  silently normalises line endings inside quoted fields on read, so the
  value is changed rather than rejected.

Fix: special-case the single-empty-value join to force explicit quoting
(unambiguous to parse back, since JoinWithEscapeCSV never otherwise
produces a bare unquoted empty field), and reject any value containing
a carriage return at join time instead of writing something that reads
back different from what was given.

Fixes cert-manager#9147

Signed-off-by: hamodywe <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. 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 Aug 15, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

Hi @hamodywe. 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 Aug 15, 2026
@wallrj
wallrj requested a lite review from Copilot August 16, 2026 05:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the correctness of the CSV join/split helpers used to serialize subject/SAN-like string slices by fixing a previously failing round-trip edge case and preventing silent value mutation.

Changes:

  • Update JoinWithEscapeCSV to (1) force explicit quoting for the []string{""} case and (2) reject any value containing \r to avoid silent CRLF normalization on read.
  • Add unit tests covering the round-trip cases (including the single-empty-value regression) and validating \r rejection.

Reviewed changes

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

File Description
pkg/util/util.go Adds join-time validation for \r and a special-case encoding for []string{""} to guarantee round-tripping with SplitWithEscapeCSV.
pkg/util/util_test.go Adds regression and round-trip unit tests for the CSV helpers, including explicit coverage for the single-empty-value case and CR rejection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/util/util.go Outdated
// is escaped with quotes if necessary
func JoinWithEscapeCSV(in []string) (string, error) {
for _, v := range in {
if strings.ContainsRune(v, '\r') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we instead check for \r\n instead of just \r.. I don't mind it as such but since encoding/csv only normalizes those it might safer to do that.. the blast radius from this is pretty low anway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, and I checked rather than guessed: a lone \r round-trips through encoding/csv untouched, including a trailing one, and only \r\n gets normalised to \n inside a quoted field.

in="lone\rCR"     -> back="lone\rCR"     round-trips
in="trailing\r"   -> back="trailing\r"   round-trips
in="\r"           -> back="\r"           round-trips
in="crlf\r\nhere" -> back="crlf\nhere"   does not

So the check as written turned away values that would have come back exactly as given. Narrowed it to \r\n in c1cf0f9, and added a value with a lone carriage return to the round-trip table so the narrower rule is pinned by a test — that case fails if the check ever goes back to rejecting every \r.

Narrowing the check to the sequence that actually cannot survive the round
trip, as raised in review.

encoding/csv normalises "\r\n" to "\n" inside a quoted field and leaves a
lone carriage return alone, so rejecting every "\r" turned away values that
would have come back exactly as they were given. Measured against
encoding/csv directly: "lone\rCR", "trailing\r" and "\r" all round-trip
unchanged; only "crlf\r\nhere" comes back as "crlf\nhere".

The round-trip table now carries a value with a lone carriage return, which
pins the narrower rule: that case fails if the check goes back to rejecting
every "\r".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: hamodywe <[email protected]>
@hjoshi123

Copy link
Copy Markdown
Collaborator

/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 Aug 23, 2026
@hjoshi123

Copy link
Copy Markdown
Collaborator

/test pull-cert-manager-master-e2e-v1-36

@hjoshi123

Copy link
Copy Markdown
Collaborator

/release-note-none

@cert-manager-prow cert-manager-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 23, 2026
@hjoshi123
hjoshi123 requested a lite review from Copilot August 23, 2026 04:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated 2 comments.

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

pkg/util/util.go:125

  • This comment says a “bare, unquoted empty field is never produced by this function for any other input”, but csv.Writer will emit unquoted empty fields when the input contains empty elements alongside others (e.g. []string{"", "a"} -> ",a"). The ambiguity you’re addressing here is specifically the empty line output for a single empty field, so the comment should be tightened to avoid stating a false guarantee.
		// encoding/csv writes a single empty field as an empty line, which
		// SplitWithEscapeCSV cannot distinguish from "no values found" on
		// read. Force explicit quoting for this one case so it round-trips;
		// a bare, unquoted empty field is never produced by this function
		// for any other input, so this is unambiguous to parse back.

pkg/util/util_test.go:292

  • The rejection test currently only checks "\r\n" (CRLF). If the intent is to reject carriage returns in general ("\r"), this test should assert that as well (and can keep CRLF as an additional case if desired).
func TestJoinWithEscapeCSVRejectsCRLF(t *testing.T) {
	_, err := JoinWithEscapeCSV([]string{"line1\r\nline2"})
	if err == nil {
		t.Fatal("JoinWithEscapeCSV with a value containing \\r\\n did not return an error, so it would silently corrupt on round trip")
	}

Comment thread pkg/util/util.go Resolved
Comment thread pkg/util/util_test.go Resolved
@cert-manager-prow cert-manager-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 23, 2026
Comment thread pkg/util/util.go Resolved
Signed-off-by: Hemant Joshi <[email protected]>
@hjoshi123

Copy link
Copy Markdown
Collaborator

/label tide/merge-method-squash

@cert-manager-prow cert-manager-prow Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 23, 2026
@hjoshi123

Copy link
Copy Markdown
Collaborator

Once the tests passes, this looks good to me to merge

/lgtm
/approve

@cert-manager-prow cert-manager-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Aug 23, 2026

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @hamodywe — the change is internally sound (the "" encoding is genuinely unambiguous, and the round trip holds under a large fuzz), but the new error path has consequences at the call sites this PR doesn't touch: it can wedge fresh issuance and silently halt post-issuance reconciliation for existing Secrets. Details and a suggested direction in the inline comments; the short version is that the CRLF handling belongs in AnnotationsForCertificate (degrade the one offending annotation) and the rejection belongs on SplitWithEscapeCSV, the parser that receives untrusted input.

A few description nits, since the release note ships verbatim:

  • The description names TestJoinWithEscapeCSVRejectsCarriageReturn, but the test is TestJoinWithEscapeCSVRejectsCRLF.
  • The title says "reject CR", but only the \r\n pair is rejected — a lone \r round-trips, as your own test shows.
  • The release-note sentence ("now reject values containing CRLF with new lines instead of silently altering them") doesn't parse; worth rewording before merge.

with claude fable-5

Comment thread pkg/util/util.go Outdated
// rather than writing a value that reads back different from what was
// given. A carriage return on its own does survive the round trip, so
// only the pair is rejected.
return "", fmt.Errorf("value %q contains a CRLF sequence, which cannot round-trip through CSV encoding", v)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for closing the loop from #9149 — the analysis in the description is right, but I think this rejection sits at the wrong layer. It turns a previously-dead error path live at two call sites, with rough consequences:

  1. Fresh issuance wedges. AnnotationsForCertificate is called from setValues before the Secret is written. The webhook does no content validation on subject strings and CRLF is legal in a UTF8String, so a CA will sign a certificate with \r\n in a subject field — and that certificate now errors before the Secret Apply. The revision never bumps, the Issuing condition never clears, and failedIssuanceAttempts never increments, so the controller retries on workqueue backoff forever against input it cannot change. Before this PR that input issued fine (the CRLF was CSV-quoted into the annotation). Same hard fail on the temporary-certificate path.

  2. Post-issuance reconciliation silently halts for existing Secrets on upgrade. certificateDataAnnotationsForSecret now errors on a stored certificate containing CRLF; SecretCertificateDetailsAnnotationsMismatch is second in the post-issuance chain and the chain short-circuits, so SecretTemplate metadata, keystores, additional output formats and owner references are never reconciled again for that Secret. The consumer swallows the InvalidCertificate violation with return nil and the Certificate stays Ready=True, so the only trace is one log line per resync.

  3. Smaller: one un-encodable field discards all twelve annotations via the sticky encodingErr, rather than just the offending one.

Suggestion: keep the guard's intent, but move the CRLF handling up into AnnotationsForCertificate — skip or sanitise the single offending annotation (it is derived metadata, not payload), so issuance keeps working — and put the rejection on SplitWithEscapeCSV instead. That function is the only production parser, and it is fed user-authored Ingress/Gateway annotations; today it still silently normalises a quoted \r\n to \n and drops an unquoted trailing \r (verified against Go's encoding/csv reader), which is exactly the silent corruption this PR set out to close — while the Join-side guard protects output that nothing in-tree ever parses back. Also worth noting JoinWithEscapeCSV is exported, so downstream importers see a total function become partial.

Comment thread pkg/util/util.go
// No other input produces exactly `""` as the entire output (a literal
// quote character would be encoded as `""""`), so this is unambiguous
// to parse back.
return `""`, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The uniqueness argument is sound — I checked that no other input joins to exactly "" — but this changes a documented annotation value. On upgrade, an existing Secret whose certificate has a single empty subject value gets a one-time rewrite when the mismatch check compares the recomputed "" against the stored empty string. That converges, but it bumps resourceVersion and wakes watchers, so it deserves a mention in the release note. More awkward: the altNames != "" guard in ingress-shim no longer treats the value as empty, so cert-manager.io/alt-names: '""' copied from a Secret onto an Ingress appends an empty DNS name to spec.dnsNames instead of being ignored (that path splits on commas, not via SplitWithEscapeCSV).

Comment thread pkg/util/util.go Outdated
@@ -105,6 +105,28 @@ func EqualKeyUsagesUnsorted(s1, s2 []cmapi.KeyUsage) bool {
// JoinWithEscapeCSV returns the given list as a single line of CSV that
// is escaped with quotes if necessary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The doc comment is now stale: it mentions neither the error, the "" return, nor that len(in) == 0 is deliberately exempt from the round-trip guarantee — JoinWithEscapeCSV(nil) still returns "", which SplitWithEscapeCSV rejects with "no values found", and that case is hit for nearly every certificate because alt-names/ip-sans/uri-sans are written with keepEmpty=true. The exemption is worth an explicit comment precisely so nobody "fixes" it later: widening this guard to cover the empty slice would change three annotations on every Secret in every cluster and cause a mass rewrite on upgrade.

Comment thread pkg/util/util.go Outdated
func JoinWithEscapeCSV(in []string) (string, error) {
for _, v := range in {
if strings.Contains(v, "\r\n") {
// encoding/csv's reader silently normalises "\r\n" to "\n" inside a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

House style here is US English in code comments: "normalizes". (The property test on #9149 that found this bug already spells it that way, so the tree would otherwise be inconsistent.)

Comment thread pkg/util/util_test.go
return ips
}

func TestJoinSplitWithEscapeCSVRoundTrip(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This table covers the same ground as the round-trip property test on #9149 that found both of these counterexamples. Once both PRs land, I'd rather relax that test's Assume exclusions to \r\n-only than pin the shrinker's counterexamples in a third place (helper_test.go already asserts some of this too). TestJoinWithEscapeCSVRejectsCRLF is worth keeping either way — a rejection isn't expressible as a round-trip property.

…nnotation

Follow-up on review: keep the guard's intent, but put it where it cannot block
issuance.

JoinWithEscapeCSV is total again. Rejecting a CRLF there turned a
previously-dead error path live at two call sites that cannot afford one.
AnnotationsForCertificate runs between signing and the Secret Apply, so an
error stranded a certificate a CA had already signed: the revision never
bumped, the Issuing condition never cleared, and failedIssuanceAttempts never
incremented, leaving the controller retrying on workqueue backoff against
input it cannot change. It also runs inside the post-issuance policy chain,
where an error short-circuits the checks that reconcile SecretTemplate
metadata, keystores, additional output formats and owner references, with the
violation swallowed by the consumer and the Certificate left Ready=True.

The rejection now sits on SplitWithEscapeCSV, the only production parser and
the one fed user-authored Ingress and Gateway annotations. It rejects exactly
the two inputs encoding/csv reads back as something else: a CRLF inside a
quoted field, which the reader rewrites as a line feed, and a carriage return
at the end of the input, which it drops. A carriage return anywhere else
survives the parse unchanged and is left alone.

AnnotationsForCertificate drops the single offending annotation instead of
discarding all twelve through a sticky error. These annotations are derived
metadata, not the issued payload, so a value that cannot be read back costs
its own annotation and nothing else. With no failure left to report the error
return is gone, so the guarantee that this function cannot block issuance is
structural rather than a promise. The empty slice is explicitly exempt from
the round-trip check: alt-names, ip-sans and uri-sans are written with
keepEmpty=true, and joining to "" is what nearly every Secret already carries.

Also documents the `""` encoding and that exemption on JoinWithEscapeCSV so
nobody widens it later, and spells "normalizes" the way the rest of the tree
does.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: hamodywe <[email protected]>
@cert-manager-prow cert-manager-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 25, 2026
@hamodywe hamodywe changed the title fix(util): round-trip a single empty value through JoinWithEscapeCSV/SplitWithEscapeCSV, reject CR fix(util): reject CSV input that cannot be read back unchanged, round-trip a single empty value Aug 25, 2026
@hamodywe

Copy link
Copy Markdown
Contributor Author

/kind bug

@cert-manager-prow cert-manager-prow Bot added kind/bug Categorizes issue or PR as related to a bug. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Aug 25, 2026
@hamodywe

Copy link
Copy Markdown
Contributor Author

Thanks for this -- the two call sites were the part I hadn't followed through, and you're right that the guard was on the wrong side. Pushed the rework in edc6dfd.

What it does now:

  • JoinWithEscapeCSV is total again. No error path, so neither setValues nor the policy chain can be stopped by it.
  • The rejection moved to SplitWithEscapeCSV. I narrowed it to only what encoding/csv actually reads back as something else, measured against the reader directly: a \r\n inside a quoted field (comes back as \n) and a carriage return at the very end of the input (dropped). A carriage return anywhere else survives the parse, quoted or not, so it is left alone. That is also why the old title was wrong twice over.
  • AnnotationsForCertificate drops the one annotation that cannot be read back, rather than all twelve. It checks by round-tripping the joined string, with the empty slice explicitly exempt -- widening that would have rewritten alt-names, ip-sans and uri-sans on every Secret in existence, which I've now written into the doc comment so it doesn't get "fixed" later.

One decision I'd like your call on: since nothing can fail there any more, I removed the error return from AnnotationsForCertificate instead of leaving it always-nil. It costs a branch each at the two call sites and it's an internal/ function, so nothing downstream sees it -- but it does make the diff bigger than the fix. Say the word and I'll put the signature back.

Description and release note are rewritten. The one-time annotation rewrite for a single empty subject value is in the note now. I left the alt-names: '""' edge in ingress-shim alone since it needs a certificate with exactly one empty DNS name plus a hand-copied annotation, but it's a two-line guard if you'd rather close it here.

On the test overlap with #9149 -- agreed, relaxing the Assume exclusions there is the better home. I've kept TestJoinSplitWithEscapeCSVRoundTrip only as the regression for the [""] case and I'm happy to drop it once yours lands.

./pkg/util/..., ./internal/controller/certificates/..., ./pkg/controller/certificates/... and ./pkg/controller/certificate-shim/... are green, and I revert-checked both new guards.

@wallrj wallrj mentioned this pull request Sep 1, 2026
39 of 41 tasks

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @hamodywe — this is exactly the rework I was hoping for, and the description now reads as the design record for the change. Answers to your three open questions:

  1. Keep the error removal from AnnotationsForCertificate. A signature that cannot fail is a stronger statement than an always-nil error — the previous revision's wedge existed precisely because a dead error path was sitting there waiting to come alive. It's internal/, both call sites got simpler, and the doc comment now explains why the function must not fail. The larger diff is the fix.

  2. Leave the alt-names: '""' ingress-shim edge out. It needs a certificate with exactly one empty DNS name plus a hand-copied annotation; closing it here would widen the PR for a path nobody has hit. If it ever bites, it's a self-contained follow-up.

  3. Keep TestJoinSplitWithEscapeCSVRoundTrip as the [""] regression for now. Once #9149 lands I'll relax its Assume exclusions to cover what this PR fixed, and the table can shrink then.

One observation for the record, not blocking: the blanket strings.Contains(in, "\r\n") also rejects a trailing CRLF used as a line terminator, which encoding/csv previously consumed losslessly — I checked against the reader directly: "GB\r\n" parses to ["GB"] with the value unchanged, so this one input class was accepted before and errors now. It isn't in your "read back as something else" table because the value doesn't change. I'm fine with the over-rejection — the rule stays one line, the error is clear, and an annotation ending in \r\n is vanishingly rare — but it belongs in the record in case anyone ever reports it. I also confirmed the guards are precise where it matters: a quoted trailing "a\r" parses back unchanged and is correctly accepted.

Also verified: the empty-slice exemption is now pinned from three directions (the JoinWithEscapeCSV doc comment, the AnnotationsForCertificate comment, and the existing keepEmpty tests), the revert-check covers both new guards, and prow is green.

with claude fable-5.1

@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hjoshi123, wallrj

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

The pull request process is described 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

@wallrj

wallrj commented Sep 3, 2026

Copy link
Copy Markdown
Member

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 8413ee8 into cert-manager:master Sep 3, 2026
6 checks passed
@wallrj wallrj mentioned this pull request Nov 4, 2026
2 of 40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JoinWithEscapeCSV/SplitWithEscapeCSV cannot round-trip a single empty value, and silently corrupt values containing CRLF

4 participants