Skip to content

fix: Format []ByRegexOption correctly.#118

Merged
JeffFaer merged 4 commits intomainfrom
jfaer/by_regex_mapping
Mar 24, 2026
Merged

fix: Format []ByRegexOption correctly.#118
JeffFaer merged 4 commits intomainfrom
jfaer/by_regex_mapping

Conversation

@JeffFaer
Copy link
Collaborator

@JeffFaer JeffFaer commented Mar 9, 2026

If there's a mix of mappings and singular elements, the mappings will
(maybe) be quoted correctly but the singular elements won't be, which
can result in a a different YAML flow sequence or even invalid YAML if the singular element has the right special characters.

e.g. Before the changes to options.go, the test was generating a different flow sequence with 3 elements instead of 2: by_regex=[foo, bar, \"\\\\b(\\\\d{2})/(\\\\d{2})/(\\\\d{4})\\\\b\": \"${3}-${1}-${2}\"]"

We now generate strings that include mapping braces ({ and }, e.g. by_regex=['foo, bar', {'\b(\d{2})/(\d{2})/(\d{4})\b': '${3}-${1}-${2}'}]). That's less than ideal, but it's still better than generating invalid YAML. I don't see any options in the YAML library to turn those braces off :/ https://pkg.go.dev/gopkg.in/yaml.v3

JeffFaer added 3 commits March 9, 2026 15:15
If there's a mix of mappings and singular elements, the mappings will
(maybe) be quoted correctly but the singular elements won't be, which
can result in a YAML flow sequence that's not valid YAML.
@JeffFaer JeffFaer requested a review from KatrinaHoffert March 9, 2026 21:56
@JeffFaer JeffFaer enabled auto-merge (squash) March 10, 2026 15:17
Copy link
Member

@KatrinaHoffert KatrinaHoffert left a comment

Choose a reason for hiding this comment

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

takeYAMLSeriously: "no"

auto-merge was automatically disabled March 24, 2026 14:27

Pull Request is not mergeable

@JeffFaer JeffFaer enabled auto-merge (squash) March 24, 2026 14:27
@JeffFaer JeffFaer merged commit e2a9a7f into main Mar 24, 2026
9 checks passed
@JeffFaer JeffFaer deleted the jfaer/by_regex_mapping branch March 24, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants