Skip to content

fix: Format []ByRegexOption correctly.#118

Open
JeffFaer wants to merge 3 commits intomainfrom
jfaer/by_regex_mapping
Open

fix: Format []ByRegexOption correctly.#118
JeffFaer wants to merge 3 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
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.

1 participant