Skip to content

A repeated tag key is sent twice and counted twice #31

Open

Description

@dmccoystephenson

Problem

Report takes its tags as IEnumerable<KeyValuePair<string, string>>, so a list can repeat a key. Json writes every pair it is given (src/TraceClient/TraceClient.cs, the foreach over tags), and no step merges them. Two pairs with the key k are sent as:

{"application":"App","name":"n","tags":{"k":"first","k":"second"}}

RFC 8259 says object member names SHOULD be unique and that behaviour on duplicates is unpredictable. Each repeated pair also counts toward MaxTags, so a list of 33 identical pairs is dropped as more than 32 tags, although it holds one distinct key.

A Dictionary cannot produce this, so only programs passing a list or an array are affected. WithVersion and WithInstall also stop at presence: a list that repeats version is sent with both values.

Current behaviour is pinned by Json_WritesARepeatedTagKeyOncePerPairAndCountsEach, added in #30.

Why this is a decision, not an auto-fix

Any change alters what goes on the wire, so the dev loop treats it as a contract change. These points need a maintainer's answer:

  1. Should a repeated key be merged, and if so, should the first or the last value win? version and install already follow "the event's own tag wins", which does not settle the order among an event's own tags.
  2. Is it enough to document this, given that the comment above Json calls the tags a flat string map?

The trace server's handling of a duplicate key was not inspected. The Java and Python clients were not inspected either, though both are expected to take a map, which cannot repeat a key.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions