elastic / apm-data

apm-data holds definitions and code for manipulating Elastic APM data
Apache License 2.0
13 stars 26 forks source link

Validation of `[null]` slice for `[]int` should not pass #271

Open lahsivjar opened 6 months ago

lahsivjar commented 6 months ago

With empty slices the validation will fail. Example:

{"metadata": {"user": {"username": "logged-in-user", "id": "axb123hg", "email": "user@mail.com"}, "labels": {"tag0": null, "tag1": "one", "tag2": 2}, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "testme-12a3", "node": {"configured_name": "node-1"},"language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node", "activation_method": "some_activation_method"}, "environment": null, "framework": null,"version": null, "runtime": null}}}
{"metricset": { "samples": { "latency_distribution": { "type": "histogram", "unit": "s", "counts": [], "values": [] } }, "timestamp": 1496170421368000 }}

But with null values in the slices validation will not fail. Example:

{"metadata": {"user": {"username": "logged-in-user", "id": "axb123hg", "email": "user@mail.com"}, "labels": {"tag0": null, "tag1": "one", "tag2": 2}, "process": {"ppid": null, "pid": 1234, "argv": null, "title": null}, "system": null, "service": {"name": "testme-12a3", "node": {"configured_name": "node-1"},"language": {"version": null, "name":"ecmascript"}, "agent": {"version": "3.14.0", "name": "elastic-node", "activation_method": "some_activation_method"}, "environment": null, "framework": null,"version": null, "runtime": null}}}
{"metricset": { "samples": { "latency_distribution": { "type": "histogram", "unit": "s", "counts": [null], "values": [null] } }, "timestamp": 1496170421368000 }}

I think both should have the same behavior.