-
Notifications
You must be signed in to change notification settings - Fork 24
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
parser: return errors if there are syntax bugs in metric names wrapped by a function #330
Conversation
eb6a810
to
540ea62
Compare
…d by a function In the current implementation, carbonapi returns 400 errors for queries like ns1.ns2.foo-[a b] or ns1.ns2.foo-{a, b}. However, if these types of queries happened to be wrapped around within a function, like sumSeries, that accepts metrics list, no errors are returned. As they are treated as individual metrics and sent to storage, storage would returns 400 as well. This commit fixes the issue, by generating a parser error if spaces and comma appears inappropriately within []/{}. At the same time, nested range list (like [[]]) and unclosed ([/{) or unopened (]/}) ranges or value list are also reported as errors, instead of treating them as proper query and forwarding them to storages. As consequence of this change, some of the requests that are originally returning 200 would be returned with 400 status codes.
540ea62
to
bd2bfe0
Compare
* Ignoring makezero due to panics in the package * Ignoring errorlint temporarilly * Update golangci-lint to version v1.40.1
bd2bfe0
to
b3e5511
Compare
@bom-d-van Can we please keep different changes in separate PRs? Linter change makes sense to do separately, and then back-merge from |
@bom-d-van I believe, we need to manually test a change in syntax like this one before merging to |
I would appreciate we just do it in one MR. The commit is already different. |
I already tested it on a staging server. What else do you propose? |
Sure. I'd appreciate if we did it in the future though. |
Great. This is exactly what I had in mind. |
a08e802
to
81bf8cc
Compare
What issue is this change attempting to solve?
In the current implementation, carbonapi returns
400
errors for queries like ns1.ns2.foo-[a b] or ns1.ns2.foo-{a, b}.However, if these types of queries happened to be wrapped around within a function, like sumSeries, that accepts
metrics list, no errors are returned. As they are treated as individual metrics and sent to storage, storage would
returns 400 as well.
How does this change solve the problem? Why is this the best approach?
This commit fixes the issue, by generating a parser error if spaces and comma appears inappropriately within []/{}.
At the same time, nested range list (like [[]]) and unclosed ([/{) or unopened (]/}) ranges or value list are also
reported as errors, instead of treating them as proper query and forwarding them to storages.
As consequence of this change, some of the requests that are originally returning 200 would be returned with 400
status codes.
How can we be sure this works as expected?
Original tests still pass and new test cases are added.