graphite error "'ParseResults' object has no attribute 'raw'" when call /render

Viewed 393

I installed graphite ( whisper - carbon - graphite-web ) with the pip method.

I connect it to my puppetserver instance ( need graphite to have jrubies informations ).

But when i try to export the data from graphite to my grafana I have an error: AttributeError: ParseResults object has no attribute raw when I add the datasource.

And on the graphite-web logfile I have:

2021-11-08,16:11:04.396 :: Exception encountered in <POST http://localhost:9091/render>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/graphite/webapp/graphite/errors.py", line 101, in new_f
    return f(*args, **kwargs)
  File "/opt/graphite/webapp/graphite/render/views.py", line 130, in renderView
    data.extend(evaluateTarget(requestContext, targets))
  File "/opt/graphite/webapp/graphite/render/evaluator.py", line 18, in evaluateTarget
    pathExpressions = extractPathExpressions(requestContext, targets)
  File "/opt/graphite/webapp/graphite/render/evaluator.py", line 205, in extractPathExpressions
    target = grammar.parseString(target)
  File "/opt/graphite/webapp/graphite/render/grammar.py", line 12, in parseString
    return _grammar.parseString(instring)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 1097, in parse_string
    loc, tokens = self._parse(instring, 0)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 5094, in parseImpl
    return super().parseImpl(instring, loc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 4265, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 5094, in parseImpl
    return super().parseImpl(instring, loc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 4265, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 4265, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
 File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 3781, in parseImpl
    instring, loc, doActions, callPreParse=False
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 4017, in parseImpl
    instring, loc, doActions,
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 824, in _parseNoCache
    tokens = fn(instring, tokensStart, retTokens)
  File "/usr/local/lib/python3.6/site-packages/pyparsing/core.py", line 282, in wrapper
    ret = func(*args[limit:])
  File "/opt/graphite/webapp/graphite/render/grammar_unsafe.py", line 83, in setRaw
    toks[0].raw = s[toks[0].start:toks[0].end]
AttributeError: 'ParseResults' object has no attribute 'raw'

Is anyone could help me to understand why I have this error and how fix it ? Thanks in Advance

2 Answers

+1 Got the same exact error today on a new Graphite installation ... otherwise exploring the metrics and retrieving data seem to be working properly.

2021-11-10,18:31:03.882 :: Exception encountered in <POST https://10.224.115.43:3001/render>
Traceback (most recent call last):
  File "/opt/graphite/lib/python3.9/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/graphite/webapp/graphite/errors.py", line 101, in new_f
    return f(*args, **kwargs)
  File "/opt/graphite/webapp/graphite/render/views.py", line 129, in renderView
    data.extend(evaluateTarget(requestContext, targets))
  File "/opt/graphite/webapp/graphite/render/evaluator.py", line 18, in evaluateTarget
    pathExpressions = extractPathExpressions(requestContext, targets)
  File "/opt/graphite/webapp/graphite/render/evaluator.py", line 205, in extractPathExpressions
    target = grammar.parseString(target)
  File "/opt/graphite/webapp/graphite/render/grammar.py", line 12, in parseString
    return _grammar.parseString(instring)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 1097, in parse_string
    loc, tokens = self._parse(instring, 0)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 5098, in parseImpl
    return super().parseImpl(instring, loc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 4267, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 5098, in parseImpl
    return super().parseImpl(instring, loc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 4267, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 4267, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 3780, in parseImpl
    loc, resultlist = self.exprs[0]._parse(
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 787, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 4016, in parseImpl
    return e._parse(
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 824, in _parseNoCache
    tokens = fn(instring, tokensStart, retTokens)
  File "/opt/graphite/lib/python3.9/site-packages/pyparsing/core.py", line 282, in wrapper
    ret = func(*args[limit:])
  File "/opt/graphite/webapp/graphite/render/grammar_unsafe.py", line 83, in setRaw
    toks[0].raw = s[toks[0].start:toks[0].end]
AttributeError: 'ParseResults' object has no attribute 'raw'

UPDATE: reinstalling pyparsing with version 2.4.7 (the one I have in another working environment) instead of 3.0.4 (the one presenting the error) seems to solve the problem.

I encountered this today as well. Graphite was displaying standard data just fine but I couldn't run any functions against the data (averageSeries, sumSeries, etc). These requests would all result in an error 500 in the browser with the same stack you've posted above. The release notes for pyparsing==3.0.4 describe this as intended behavior:

result = Word(alphas).parseString("abc") result.xyz = 100

now raises this Python exception:

AttributeError: 'ParseResults' object has no attribute 'xyz'

To add new attribute values to ParseResults object in 3.0.0 and later, you must assign them using indexed notation:

result["xyz"] = 100

And if you check the referenced line in your stack (grammar_unsafe.py line 83) you'll see that Graphite is indeed attempting to assign the 'raw' attribute without using the indexed notation. I attempted to edit this line with varying results. Some graphs would render but there were other issues with apache restart, so simply updating the notation used in setting toks[0].raw only complicates the issue. I've logged an issue with graphite-web and in the interim, have downgraded my pyparsing to 2.4.7 as suggested in the recommended answer.

Related