w3c / w3c/json-ld-api

compaction: 12.7.1 empty array to 7.3 IRI compaction candidate

Open
#701 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
106
Forks
40
PR merge metrics
No merged PRs in 30d

Description

During a refactor of my compaction implementation I ended up with an unfortunate interaction where instead of passing the empty array as the value through in 12.7.1, a null ended up going through. This then caused the wrong candidate to be selected in IRI compaction in 7.3, due to the value is null check.

The test suite lacks coverage for this, but a reproducer looks like this:

{
  "@id": "http://example.org/id",
  "http://example.org/prop": []
}
{
  "ex": "http://example.org/",
  "ex:prop": { "@id": "http://example.org/prop", "@container": "@list" }
}
{
  "@context": {
    "ex": "http://example.org/",
    "ex:prop": { "@id": "http://example.org/prop", "@container": "@list" }
  },
  "@id": "ex:id",
  "http://example.org/prop": []
}

If a nil/null is passed through instead of the empty array, you end up with ex:prop instead of http://example.org/prop.

This could potentially be folded into t0004?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied JSON-LD reproducer and the existing test suite, checking whether this case belongs in t0004. Trace the empty-array value through compaction steps 12.7.1 and 7.3, then add regression coverage showing that the full IRI candidate is selected instead of the compact term.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.