web api: handle alert with Infinity/NaN values#5582
Merged
brian-brazil merged 2 commits intoprometheus:masterfrom May 21, 2019
Merged
web api: handle alert with Infinity/NaN values#5582brian-brazil merged 2 commits intoprometheus:masterfrom
brian-brazil merged 2 commits intoprometheus:masterfrom
Conversation
4e345d0 to
15dc2f6
Compare
Contributor
|
5303 would be the preferred way of handling this, if you'd like to take it
over.
…On Mon 20 May 2019, 15:23 Alex Salt, ***@***.***> wrote:
The problem:
- json-iterator/go library encodes math.Inf and math.NaN as is (which
is invalid json spec), where standard encoding/json raises an error:
json-iterator/go#365 <json-iterator/go#365>
The only solution I see is to return 0 instead of Infinity/NaN values.
There is a pull request (#5303
<#5303>), but it is not
correct and seems to be abandoned
------------------------------
You can view, comment on, or merge this pull request online at:
#5582
Commit Summary
- web/api/v1: sanitize alert values
File Changes
- *M* web/api/v1/api.go
<https://github.com/prometheus/prometheus/pull/5582/files#diff-0> (10)
Patch Links:
- https://github.com/prometheus/prometheus/pull/5582.patch
- https://github.com/prometheus/prometheus/pull/5582.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5582?email_source=notifications&email_token=ABWJG5XE2PYP2Z6GWRAMDKLPWKQ57A5CNFSM4HOB55VKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUXF6IA>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABWJG5RRY4Y6U47IPIAVLCTPWKQ57ANCNFSM4HOB55VA>
.
|
Member
|
This isn't the correct change: the solution would be to return a string value, see #5303 (review). |
Contributor
Author
|
You mean return number if it is valid or string if it is not? |
Contributor
|
Always return a string.
…On Mon 20 May 2019, 17:31 Alex Salt, ***@***.***> wrote:
You mean return number if it is valid or string if it is not?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5582?email_source=notifications&email_token=ABWJG5SIYSAATYHNJ6QOIMTPWK73ZA5CNFSM4HOB55VKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVZGRAQ#issuecomment-494037122>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABWJG5THKI7ZYQTNWEHNOM3PWK73ZANCNFSM4HOB55VA>
.
|
Contributor
Author
|
It will still break clients which expect a number, I can fix go client, but I don’t know about others. Are you ok with that? |
Contributor
|
Yes, that's acceptable here and in line with what we do for the query api. |
15dc2f6 to
b6ddfe1
Compare
Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
b6ddfe1 to
0a39c07
Compare
Contributor
Author
|
I've updated api to return alert value as a string. |
Contributor
|
Looks good, docs also need updating, |
Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
Contributor
|
Thanks! |
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem:
json-iterator/golibrary encodesmath.Infandmath.NaNas is (which is invalid json spec), where standardencoding/jsonraises an error: json: +-Inf and NaN json-iterator/go#365The solution I see is to return 0 instead of Infinity/NaN values.
There is a pull request (#5303), but it is not correct and seems to be abandoned