w3c / w3c/json-ld-api

expansion: string @value must not get @language/@direction if type mapping exists

Open
#700 2 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

I ended up with a bug in my implementation where Step 5 of value expansion (https://www.w3.org/TR/json-ld11-api/#algorithm-5) always happened if the value was a string, even if a type mapping was present. The test suite lacks coverage for this case, so this bug went unnoticed for almost a year.

A simple reproducer:

{
  "@context": {
    "typed": { "@id": "http://ex/typed", "@type": "http://ex/dt" },
    "@language": "und"
  },
  "typed": "v"
}

Expected:

[
  {
    "http://ex/typed": [
      {
        "@type": "http://ex/dt",
        "@value": "v"
      }
    ]
  }
]

Due to my bug I ended up with an "@language": "und" on http://ex/typed as well.

The Pleroma/Akkoma lineage of fediverse instances, as well as Mobilizon, all smash a {"@language": "und"} in their context.

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 Step 5 value-expansion algorithm and the existing test suite for value expansion. Use the JSON-LD context and reproducer in the issue as the regression case, then verify that a string with a type mapping produces @type and @value without @language or @direction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.