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

Handle regex parsing errors in Gsub and Grok Processors #17260

Merged
merged 1 commit into from Mar 29, 2016

Conversation

talevy
Copy link
Contributor

@talevy talevy commented Mar 22, 2016

Currently, both Gsub and Grok parse regex strings during
Pipeline creation. Thrown parsing exceptions were leaking out, this
commit wraps those exceptions in ElasticsearchParseExceptions.

Gsub Example

{
  "pipeline": {
    "processors": [
      {
        "gsub": {
          "tag": "processor_1",
          "field": "message",
          "pattern": "[",
          "replacement": ""
        }
      }
    ]
  }
}

expected error:

{
   "error": {
      "root_cause": [
         {
            "type": "parse_exception",
            "reason": "[pattern] Invalid regex pattern. Unclosed character class near index 0\n[\n^",
            "header": {
               "processor_type": "gsub",
               "processor_tag": "processor_1",
               "property_name": "pattern"
            }
         }
      ],
      "type": "parse_exception",
      "reason": "[pattern] Invalid regex pattern. Unclosed character class near index 0\n[\n^",
      "header": {
         "processor_type": "gsub",
         "processor_tag": "processor_1",
         "property_name": "pattern"
      }
   },
   "status": 400
}

Grok Example

{
  "pipeline": {
    "processors": [
      {
        "grok": {
          "tag": "processor_1",
          "field": "message",
          "pattern": "["
        }
      }
    ]
  }
}

and expected error:

{
   "error": {
      "root_cause": [
         {
            "type": "parse_exception",
            "reason": "[pattern] Invalid regex pattern. premature end of char-class",
            "header": {
               "processor_type": "grok",
               "processor_tag": "processor_1",
               "property_name": "pattern"
            }
         }
      ],
      "type": "parse_exception",
      "reason": "[pattern] Invalid regex pattern. premature end of char-class",
      "header": {
         "processor_type": "grok",
         "processor_tag": "processor_1",
         "property_name": "pattern"
      }
   },
   "status": 400
}

@talevy talevy added WIP :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP labels Mar 22, 2016
Currently, both Gsub and Grok parse regex strings during
Pipeline creation. Thrown parsing exceptions were leaking out, this
commit wraps those exceptions in ElasticsearchParseExceptions.
@martijnvg
Copy link
Member

LGTM

@talevy talevy merged commit 16e888f into elastic:master Mar 29, 2016
@talevy talevy deleted the fix-regex-exceptions branch March 29, 2016 15:12
@talevy talevy removed the review label Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP v5.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants