Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse only comma-less field part as field #2936

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Voker57
Copy link

@Voker57 Voker57 commented Apr 14, 2024

Motivation

Multiple field parsing is broken: even if proper string is passed to the parser, commas are parsed as part of the field
This partially fixes #2935

Solution

Pass only 1st capture group to the field parser, instead of the whole string

@Voker57 Voker57 requested review from hawkw, davidbarsky and a team as code owners April 14, 2024 14:13
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

This looks good to me. Would you mind adding a test for a filter expression that would previously have been parsed incorrectly? Thanks!

@Voker57
Copy link
Author

Voker57 commented Apr 27, 2024

This looks good to me. Would you mind adding a test for a filter expression that would previously have been parsed incorrectly? Thanks!

I fixed the test, however it will fail both with and without my modification because commas are parsed earlier as delimiters for multiple filters. I'm not sure how to fix this, honestly the whole parsing system is a mess and should be rewritten using a parser combinator. For my usage I changed the filter delimiter to +, can prepare a patch if you don't mind compatibility breaking in such a way. Also, I replaced EnvFilter::new with try_new to make errors fail test, this should be done for all tests and maybe you'll discover many other interesting things.

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.

parsing multiple field values in EnvFilter is broken
2 participants