graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.89k stars 1.26k forks source link

Raise exception when not recoverable #2740

Closed replay closed 2 years ago

replay commented 2 years ago

The helper handleInvalidParameters() only raises the given exception when settings.ENFORCE_INPUT_VALIDATION is True, if it's False then it only logs an error and swallows the exception with the intention to try whether the query may succeed despite the invalid input.

But if a data processing function has raised an exception, then this is not recoverable and there is no point in continuing to try whether the execution still succeeds.

This also improves the returned error when ENFORCE_INPUT_VALIDATION is False, because without this change the execution will continue and then a not very useful exception gets raised by evaluateScalarTokens().

This is with the current master and ENFORCE_INPUT_VALIDATION=False:

$ curl 'http://localhost:8000/render' -d format=json -d 'target=divideSeries(some.id.of.a.metric.1, "abc")'
Invalid parameters (unknown token in target evaluator); targets: "divideSeries(some.id.of.a.metric.1, "abc")"

And in this branch:

$ curl 'http://localhost:8000/render' -d format=json -d 'target=divideSeries(some.id.of.a.metric.1, "abc")'
Invalid parameters (divideSeries second argument must reference exactly 1 series (got 3)); targets: "divideSeries(some.id.of.a.metric.1, "abc")"; func: "divideSeries([TimeSeries(name=some.id.of.a.metric.1, start=1588698400, end=1588784800, step=10, valuesPerPoint=1, consolidationFunc=average, xFilesFactor=0.0)], 'abc')"
deniszh commented 2 years ago

πŸ’š All backports created successfully

Status Branch Result
βœ… 1.1.x

Questions ?

Please refer to the Backport tool documentation

deniszh commented 2 years ago

πŸ’š All backports created successfully

Status Branch Result
βœ… 1.1.x

Questions ?

Please refer to the Backport tool documentation

deniszh commented 2 years ago

πŸ’š All backports created successfully

Status Branch Result
βœ… 1.1.x

Questions ?

Please refer to the Backport tool documentation