Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested contexts behavior #590

Closed
davidlehn opened this issue Feb 6, 2024 · 3 comments
Closed

Nested contexts behavior #590

davidlehn opened this issue Feb 6, 2024 · 3 comments

Comments

@davidlehn
Copy link
Contributor

How should a nested context behave?

{
  "@context": {
    "@context": {
      "p": "ex:p"
    }
  },
  "@id": "ex:1",
  "p": "value"
}

jsonld.js will expand to:

[
  {
    "@id": "ex:1",
    "ex:p": [
      {
        "@value": "value"
      }
    ]
  }
]

Ruby Distiller errors:

error
JSON::LD::JsonLdError::InvalidTermDefinition
invalid term definition: Term definition for "@context" has unexpected keys: p

Sophia errors:

Source failed: error while expanding: Expansion failed: Invalid context: Invalid term definition

If this isn't undefined behavior, there should be a positive or negative test for this case.

@gkellogg
Copy link
Member

gkellogg commented Feb 6, 2024

It is explicitly not allowed. Specific keywords in @context are called out in the context processing algorithm, everything else is a term definition. For a term definition @type is accounted for and no other keywords are allowed.

I suspect there are some tests for this, but maybe not for @context. I would be fine if such a negative test were added.

@davidlehn
Copy link
Contributor Author

Added a test in #591. I think 4.2.2.5 is the relevant spec text. Looks like jsonld.js is recursively processing objects, and pulling out the @context data if present. Works well to handle both regular context data and files with a @context key. If this is an error, it does need a test. I'm surprised this wasn't noticed before.

@davidlehn
Copy link
Contributor Author

Addressed with test for correct behavior: #591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants