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

Add error for regex with no named groups #12

Merged
merged 1 commit into from
Jul 10, 2020
Merged

Conversation

camdencheek
Copy link
Contributor

@camdencheek camdencheek commented Jul 9, 2020

Description of Changes

A common error is to use a regex pattern without any named capture groups. This errors out in that case because it's almost guaranteed to be unintended.

Sample error message:

{
  "level": "error",
  "timestamp": "2020-07-09T10:10:32.855-0400",
  "message": "Failed to start carbon log agent",
  "error": {
    "description": "build pipeline: build plugins: no named capture groups in regex pattern",
    "suggestion": "use named capture groups like '^(?P<my_key>.*)$' to specify the key name for the parsed field",
    "details": {
      "plugin_id": "$.rp",
      "plugin_type": "regex_parser"
    }
  }
}

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • CI passes

@camdencheek camdencheek requested a review from jmwilliams89 July 9, 2020 14:06
@codecov
Copy link

codecov bot commented Jul 9, 2020

Codecov Report

Merging #12 into master will increase coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #12      +/-   ##
==========================================
+ Coverage   75.93%   76.02%   +0.09%     
==========================================
  Files          60       60              
  Lines        3560     3569       +9     
==========================================
+ Hits         2703     2713      +10     
  Misses        636      636              
+ Partials      221      220       -1     
Impacted Files Coverage Δ
plugin/builtin/parser/regex.go 83.67% <100.00%> (+3.67%) ⬆️
plugin/builtin/input/tcp.go 84.72% <0.00%> (+1.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cecee58...36f2c52. Read the comment docs.

@camdencheek camdencheek merged commit 32d21f6 into master Jul 10, 2020
@camdencheek camdencheek deleted the regex-capture-warn branch July 10, 2020 15:02
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