Skip to content

@included behaves incorrectly if @context follows entry #358

Open
@hsolbrig

Description

@hsolbrig

See: http://tinyurl.com/r8chydx

If the @context entry precedes the @included, behavior is as expected. If at the end, @included maps to http://example.org/@included

Activity

gkellogg

gkellogg commented on Jan 27, 2020

@gkellogg
Collaborator

Full support for @included is in #349.

hsolbrig

hsolbrig commented on Mar 2, 2020

@hsolbrig
Author

The issue seems to have been fixed in the above example, but https://tinyurl.com/ura2qxv
still has it.

added this to the JSON-LD 1.1 milestone on Mar 11, 2020
davidlehn

davidlehn commented on Mar 11, 2020

@davidlehn
Member

A newer jsonld.js was released and the playground updated. Did that solve this issue?

hsolbrig

hsolbrig commented on Mar 11, 2020

@hsolbrig
Author

Unfortunately, I'm getting a hang when I use the above link.

davidlehn

davidlehn commented on Mar 11, 2020

@davidlehn
Member

Yup. I was hoping no one would notice. ;-) Locking the whole tab up, which is strange. Maybe something recursive in those contexts? Will have to investigate.

hsolbrig

hsolbrig commented on Mar 11, 2020

@hsolbrig
Author

Ya - the contexts are recursive as all getout -- I thought that was ok...

davidlehn

davidlehn commented on Mar 11, 2020

@davidlehn
Member

In Node.js it first flips out on https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld.

No special encoding was specified:

$ curl -I https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld
[...]
Content-Type: application/ld+json
[...]

It has BOM bytes:

$ file medicationadministration.context.jsonld 
medicationadministration.context.jsonld: UTF-8 Unicode (with BOM) text
$ curl -O https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld
$ xxd -l 16 medicationadministration.context.jsonld
00000000: efbb bf7b 0a20 2022 4063 6f6e 7465 7874  ...{.  "@context

JSON.parse isn't liking that in node:

  [...]
  name: 'jsonld.InvalidUrl',
  details: {
    code: 'loading remote context failed',
    url: 'https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld',   
    cause: SyntaxError: Unexpected token  in JSON at position 0
        at JSON.parse (<anonymous>)
        at ContextResolver._fetchContext (.../jsonld.js/lib/ContextResolver.js:159:24)
  [...]

I have no idea what tools should do with that. It's easy enough to fix, if that's the right thing to do. I don't know. I think browser is ok with it. In Node it then proceeds to blow it's heap limits and crash the vm. I assume that's what happens in the browser as well. So somewhere recursion is not handled well.

davidlehn

davidlehn commented on Mar 13, 2020

@davidlehn
Member

Working on a scoped context recursion fix: #381

davidlehn

davidlehn commented on Apr 16, 2020

@davidlehn
Member

Playground has been updated. Failing to load the files, but I think that's just due to the BOM character issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gkellogg@davidlehn@hsolbrig

        Issue actions

          `@included` behaves incorrectly if `@context` follows entry · Issue #358 · digitalbazaar/jsonld.js