RedHatInsights / insights-core

Insights Core is a data collection and processing framework used by Red Hat Insights
https://cloud.redhat.com/insights
Apache License 2.0
153 stars 183 forks source link

nginx: empty string is not allowed #4086

Closed Et7f3 closed 7 months ago

Et7f3 commented 7 months ago

Hello, I got this stack trace (with location but not filename):

Traceback (most recent call last):
  File "/var/lib/insights/last_stable.egg/insights/parsers/nginx_conf.py", line 156, in parse_doc
    return Entry(children=self.Top("\n".join(content))[0], src=self)
  File "/var/lib/insights/last_stable.egg/insights/parsr/__init__.py", line 356, in __call__
    raise Exception(err.read())
Exception: At line 9 column 33:
quoted string
    Expected 1 of ['\t', '\n', '\x0b', '\x0c', '\r', ' ', '!', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']. Got '"'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/insights/last_stable.egg/insights/core/plugins.py", line 170, in invoke
    r = self.component(d)
  File "/var/lib/insights/last_stable.egg/insights/parsers/nginx_conf.py", line 152, in __init__
    super(NginxConfPEG, self).__init__(*args, **kwargs)
  File "/var/lib/insights/last_stable.egg/insights/core/__init__.py", line 89, in __init__
    self._handle_content(context)
  File "/var/lib/insights/last_stable.egg/insights/core/__init__.py", line 92, in _handle_content
    self.parse_content(context.content)
  File "/var/lib/insights/last_stable.egg/insights/core/__init__.py", line 347, in parse_content
    self.doc = self.parse_doc(content)
  File "/var/lib/insights/last_stable.egg/insights/parsers/nginx_conf.py", line 158, in parse_doc
    raise ParseException("There was an exception when parsing the config file.")
insights.core.exceptions.ParseException: There was an exception when parsing the config file.

I digged in insight debug log and found the file that caused this:

server{
        listen 443 ssl;
        ssl_certificate /etc/nginx/certificate/nginx-certificate.crt;
        ssl_certificate_key /etc/nginx/certificate/nginx.key;
        location / { try_files $uri @api; }
        location @api {
            include fastcgi_params;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param SCRIPT_NAME "";
#                                      ^ We can't directly close ?
            fastcgi_pass localhost:5000;
        }
}

When I use nginx-t it seems fine.

I didn't have any insights of the stacktrace I just found randomly on this machine.

bfahr commented 7 months ago

@Et7f3 thank you for submitting this issue. I've investigated and although I'm not sure that there is a purpose for that particular setting, it seems reasonable that the parser should be able to handle it.

bfahr commented 7 months ago

Closing this issue with the PR #4087

Et7f3 commented 7 months ago

thanks for quick fix

do you know when it will become available on rhel9 ? Since insight downloads the egg file it should not require to update the insights-client binary ?

Closing this issue with the PR #4087

Hint you can use Github automatic closing

bfahr commented 7 months ago

@Et7f3 that change should be available in PyPI next Thursday April 25 and in production on April 29th.