bugger.
All challenges/Pythonmediumthe-payload-that-became-many-values-v1
THE INVESTIGATION

The payload that became many values

A field grouper accidentally expands binary payloads and mappings into unrelated values.

CollectionsStateRegression testing

What’s going wrong

The importer from the earlier lessons now accepts repeated fields. Some scalar values happen to support iteration; that does not make them multi-valued fields.

Input is an array of [field_name, value] pairs; field names are short strings. A JSON list value explicitly means multiple values. A string, number, boolean, null or ordinary object means one value. A top-level object with exactly the key bytes contains an integer array (0..255) representing one Python bytes payload; preserve it as that same {"bytes":[...]} object in output. List members are ordinary JSON values and are not recursively decoded.

Append repeated field names in encounter order. Empty explicit lists contribute no values or key. Empty strings, empty mappings and empty byte payloads DO contribute one scalar value. Print an array of [name, values] pairs in order of each name's first contributed value. At most 200 pairs and 1000 total list/byte members are supplied.

Expected behavior

Use semantic type boundaries instead of broad iterable capabilities.

Reproduction

01 Binary value is one field
[["file",{"bytes":[65,66]}]]
[["file",[{"bytes":[65,66]}]]]
02 Explicit list means many values
[["tag",["a","b"]]]
[["tag",["a","b"]]]
03 String stays scalar
[["name","ab"]]
[["name",["ab"]]]

Before you begin

  • Python lists and dictionaries
  • Retain falsey values, duplicates and stable order while grouping.

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.