Skip to content
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

argus merges the data fields for duplicate names #60

Closed
ilawjr opened this issue Sep 29, 2020 · 2 comments · Fixed by #130
Closed

argus merges the data fields for duplicate names #60

ilawjr opened this issue Sep 29, 2020 · 2 comments · Fixed by #130
Assignees
Labels
bug Something isn't working needs discussion Further discussion is needed to move forward
Milestone

Comments

@ilawjr
Copy link

ilawjr commented Sep 29, 2020

Currently, Argus accepts json payloads with duplicate object names e.g.
{"identifier" : "minimal0","data": {"minnie":"mouse"},"ttl":300,"identifier" : "minimal1","data": {"mickey":"mouse"},"ttl":600}

This is what's stored:
{"identifier":"minimal1","data":{"mickey":"mouse","minnie":"mouse"},"ttl":572}

Non-unique names appeared to be allowed in json, but this results in inconsistent behavior. The value for identifier & ttl are replaced by the later duplicate, but data field values are merged.

@ilawjr ilawjr added bug Something isn't working needs discussion Further discussion is needed to move forward labels Sep 29, 2020
@johnabass
Copy link

johnabass commented Feb 9, 2021

This really isn't a server bug per se. It's how the encoding/json package behaves. Incidentally, this behavior is common: most languages and platform handle duplicate fields by taking the last occurrence of that field in the stream. The JSON RFC is silent on how to unmarshal messages with duplicate fields. This is just the most common choice made by API and framework engineers.

Any way we would try to fix this in a server would result in inconsistent behavior from someone's point of view. Arguably, this is a client bug. It would be nice for our server software to detect it, but that's not really feasible given the current state of things.

@joe94
Copy link
Member

joe94 commented Feb 10, 2021

Spoke to @ilawjr and he recommended to document this in our readme as a heads up.

@joe94 joe94 added this to the v0.3.11 milestone Feb 10, 2021
@joe94 joe94 linked a pull request Feb 10, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs discussion Further discussion is needed to move forward
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants