-
Notifications
You must be signed in to change notification settings - Fork 23
Possible oversights in processing when @type
is not an IRI?
#446
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
Comments
I think you've described the correct behavior of everything. It's perhaps not as intuitive as it should be. The relative IRIs are not errors normally, and they will get through expansion, but when going to n-quads, will be dropped. If you want to see those types the issues on the JSON-LD Playground, go to the options tab and enable "safe" mode. Or use the canonized tab. In this case, it will report I'm not sure how that id is used, but as you note, it should probably be prefixed with the top level jsonld.js (used on the playground) added the "safe mode" to be more strict about acceptable JSON-LD. It raises errors in many places where the algorithms would otherwise drop data or suggest warnings. This is important when the data is canonized and digitally signed. In such cases, dropped data (and other issues) cause serious issues. It's not the default on the playground due to the official processing not having that behavior. One day hopefully the playground can make it more clear how to use that feature. "safe mode" itself needs to be written up (probably by me) and the community can refine it so it's more generally available in tooling. |
Shouldn't the |
This was discussed during the #json-ld meeting on 26 February 2025. View the transcriptw3c/json-ld-syntax#446After discussion, this does not seem to be a bug, suggest closing. |
@trwnh thanks for this detailed description. As @niklasl points out, there is nothing wrong (in theory) with the 2nd version of the ATProto example (expanded against an empty context). The the value of In the absence of a base URI (which is the playground's default), those relative IRI references can't be resolved, and are therefore silently dropped when converting to RDF. The fact that it is silent is indeed an issue, and there are plans to fix this in the future. Those plans are already implemented in the playground: in the options, select "Safe: true", and now you get the error you were expecting. |
I'm still slightly confused about what the correct behavior should be... This might be a playground bug, but putting a base IRI of "custom URL" into the options tab produces this RDF statement:
Note that "type": "#AtprotoPersonalDataServer" I say "correct" because I'm not sure it actually is correct. I don't know whether it should be a
Barring the first one which is probably wrong, that is. At least per discussion on json-ld/json-ld.org#849 there is a pointer to RFC 3886 saying exactly this:
Which I interpret as For this issue, I would say I'd consider it resolved by "safe mode" in part, and in part by fixing the expansion. To answer my own questions from the original issue (and as a quick sanity check):
These "non-IRI types" are actually relative references
They are not invalid JSON-LD but they are invalid RDF unless a base IRI is provided for expansion. The "non-IRI type" will attempt to expand against |
This issue might be better discussed on Stack Overflow, where more people might be able to help with basic usage; it does not represent a problem with the specifications, themselves. |
JSON-LD 1.1 requires
@type
to be an IRI...From 3.5 Specifying the Type: https://www.w3.org/TR/json-ld11/#specifying-the-type
From 9.16 Keywords: https://www.w3.org/TR/json-ld11/#keywords
So it seems pretty clear to me that the intent and also normative requirement is for every entry in
@type
to be an IRI, ultimately....but there are documents in the wild that don't follow this...
HOWEVER: There are documents, producers, and other specs that currently exist that use raw string literals within
type
which is aliased to@type
by a@context
declaration. Notably, ATProto has this to say: https://atproto.com/specs/did#did-documentsAt the same time, there is no ATProto-specific context document or declaration: https://web.plc.directory/did/did:plc:ewvi7nxzyoun6zhxrhs64oiz
...but it doesn't seem to cause any errors?
I would expect this to be disallowed by the JSON-LD spec, but the JSON-LD Playground seems to be okay with it?
The following non-IRI value for
@type
shows up in expanded form:When compacting against an empty context, it also seemingly works:
So, what gives?
Obviously the most correct thing here is to ask the ATProto people to provide a namespace and/or context document for their extension terms, but I'm wondering if the JSON-LD processing algorithms should detect these non-IRI types and possibly give a warning or error or otherwise elide them... or is it OK for these "non-IRI types" to exist?
Note that the RDF conversion to N-Quads (in the playground example above, for instance) will not output the
@type
of the single item indid:service
.This is partially due to a different problem that I'm not sure whether I should file an issue about or not -- relative IRI references for
@id
. In short, it seems like#atproto_pds
is not automatically picking on the"id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz"
of the top-level object.No matter; we can change the service node's identifier from
#atproto_pds
todid:plc:ewvi7nxzyoun6zhxrhs64oiz#atproto_pds
and two additional quads get output:But we don't get a quad for
rdf:type
. So this backs up the notion that the "non-IRI types" are at least invalid RDF.The question that remains: are they invalid JSON-LD as well? If not, should they be? If yes, what is to be done when processing them?
The text was updated successfully, but these errors were encountered: