Skip to content

json.decode is too strict; fails on duplicate keysΒ #15605

@alexeagle

Description

@alexeagle

Description of the bug:

A couple of packages are published to npm with a JSON descriptor which is valid in every context it's used.

However json.decode fails on this part of the file:

  "typeCoverage": {
    "atLeast": 100,
    "detail": true,
    "strict": true
  },
  "typeCoverage": {
    "atLeast": 100,
    "detail": true,
    "strict": true,
    "ignoreCatch": true
  }

More context here:
aspect-build/rules_js#148

I agree with the library author that it's really a Bazel bug, which should follow the https://en.wikipedia.org/wiki/Robustness_principle of "be permissive in what you accept". Author points this out:
wooorm/decode-named-character-reference#2
wooorm/stringify-entities#11

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

json.decode("""
{
  "typeCoverage": {
    "atLeast": 100,
    "detail": true,
    "strict": true
  },
  "typeCoverage": {
    "atLeast": 100,
    "detail": true,
    "strict": true,
    "ignoreCatch": true
  }
}
""")

What is the output of bazel info release?

5.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)team-Starlark-InterpreterIssues involving the Starlark interpreter used by Bazeltype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions