Skip to content

fix: revert string parsing in configmap to not trim spaces#3211

Closed
Cali0707 wants to merge 1 commit into
knative:mainfrom
Cali0707:revert-string-parsing-in-configmaps
Closed

fix: revert string parsing in configmap to not trim spaces#3211
Cali0707 wants to merge 1 commit into
knative:mainfrom
Cali0707:revert-string-parsing-in-configmaps

Conversation

@Cali0707
Copy link
Copy Markdown
Member

@Cali0707 Cali0707 commented Jul 7, 2025

In #3200 we switched the configmap parser to trim spaces in strings. Unfortunately, this has broken the parsing of configmaps with multi-line embedded yamls in downstream repos like eventing (see failures in knative/eventing#8618). This PR reverts the change

Changes

  • Do not trim spaces in configmap string parsing

Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Jul 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707

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

@Cali0707
Copy link
Copy Markdown
Member Author

Cali0707 commented Jul 7, 2025

/assign @dprotaso @evankanderson

@knative-prow knative-prow Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 7, 2025
@knative-prow knative-prow Bot requested review from aslom and skonto July 7, 2025 19:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.61%. Comparing base (3eb1089) to head (7f71db5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3211      +/-   ##
==========================================
- Coverage   74.63%   74.61%   -0.03%     
==========================================
  Files         209      209              
  Lines       12022    12022              
==========================================
- Hits         8973     8970       -3     
- Misses       2770     2772       +2     
- Partials      279      280       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dprotaso
Copy link
Copy Markdown
Member

dprotaso commented Jul 7, 2025

Can you clarify the problem more?

The trim'ing just trims leading and trailing whitespace

@Cali0707
Copy link
Copy Markdown
Member Author

Cali0707 commented Jul 7, 2025

Can you clarify the problem more?

The trim'ing just trims leading and trailing whitespace

Yeah, the issue we are seeing in eventing is that there are configmaps with data that looks like:

"channel-template-spec": "\tapiVersion: Foo/v1\n\tkind: Bar\n"

And since we trim the whitespace the "value" becomes:

"apiVersion: Foo/v1\tkind: Bar\n"

Resulting in an error that yaml: line 2: mapping values are not allowed in this context, when we try and convert the result from yaml to JSON (see https://github.com/knative/eventing/blob/main/pkg/reconciler/broker/config.go#L65)

Essentially, the problem is that if we try to use cm.AsString with a string that contains multiple lines of yaml, the subsequent parsing/manipulation we do of that now breaks

@dprotaso
Copy link
Copy Markdown
Member

dprotaso commented Jul 7, 2025

This honestly might be more of an issue with the fixture string in the test

eg. https://go.dev/play/p/wH7mgI5UXBO

@dprotaso
Copy link
Copy Markdown
Member

dprotaso commented Jul 7, 2025

I think I'd prefer eventing just make their own parser func to handle this YAML scenario.

The alternative would be to have all this extra validation everywhere. We'd have to trim the strings for whitespace then check if it's empty.

@Cali0707
Copy link
Copy Markdown
Member Author

Cali0707 commented Jul 7, 2025

I think I'd prefer eventing just make their own parser func to handle this YAML scenario.

The alternative would be to have all this extra validation everywhere. We'd have to trim the strings for whitespace then check if it's empty.

That's fair, I'll close this then

/close

@knative-prow knative-prow Bot closed this Jul 7, 2025
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Jul 7, 2025

@Cali0707: Closed this PR.

Details

In response to this:

I think I'd prefer eventing just make their own parser func to handle this YAML scenario.

The alternative would be to have all this extra validation everywhere. We'd have to trim the strings for whitespace then check if it's empty.

That's fair, I'll close this then

/close

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.

Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants