-
Notifications
You must be signed in to change notification settings - Fork 23
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
@protected
creates unresolvable conflicts when the same term is defined in two contexts top-level
#443
Comments
There's a typo in the controller document v1 context and it should instead use the activitystreams vocab for That being said, the whole point of protection is to enforce a particular term definition in a particular place when a particular context is present. So it is not a bug that it is doing this, but a feature. And it does require coordination to share terms across contexts in the same place (by ensuring the term definitions match). That's a requirement for the feature to work. You can only use other term definitions when you bring in a property-scoped context (as mentioned), because decentralized extensibility (in this case, reuse of the same term with a different definition) is only considered safe in different areas of the JSON tree in the same document. Of course, if specs and / or implementations allow for JSON-LD compaction to be performed, then significantly more flexibility is possible. All of these designs are around finding a balance for different kinds of consumers in a sufficiently large decentralized ecosystem, some who will only accept static documents and others who might use compaction prior to consumption. This of course creates constraints. |
If I'm reading this correctly, are you saying that two context authors are required to coordinate whenever there is a term conflict? This seems unworkable given the open-world assumption. If any single context author decides to make their term definition(s) It seems to me like this unnecessarily makes things way more complicated for polyglots or anyone wanting to implement multiple overlapping specs. If for example schema.org decided to protect their context, it would become impossible to use both activitystreams and schema.org, because numerous top-level properties like I don't see a situation that can possibly work smoothly so long as anyone uses |
Apologies, I would have written a shorter response if I had more time.
No, I'm saying that the This prohibition exists for a good reason: to enable both rigid and flexible implementations to interoperate. It is used when there is a spec that expresses, in detail, a data model and JSON format, such that implementers who read the spec can write rigid implementations "in the context of" the data as expressed in the specification. In other words, from this perspective, these specs are no different from any other specification designed around information expressed in JSON (with no capability to transform conforming documents into some other expression). These rigid implementations treat the URLs in the However, behind these Of course, enabling these two approaches at once has trade offs. Nothing is for free. Coordination is required while creating the spec and, as is always required when using a JSON spec, a conforming document must not deviate from what's in the spec or reuse terms (JSON keys) to mean something other than what is in the spec. Simply put: the use of a spec and the
It's workable, and only slightly more constrained, i.e., you can't "just use whatever term definitions you want" in your documents and expect them to be consumable by simpler implementations that are unable to understand your changes. The most basic and commonly reused term definitions from a spec are immutable. If it helps, this can be thought of as extending the set of JSON keys that JSON-LD already doesn't allow redefinition of, i.e., all keywords (e.g., Specs that use this feature require the more complex implementations to express their documents in a more rigid way (really, in a specific context) in order to enable simpler implementations to exist. However, you can, of course, express all the information you want using other terms that the spec doesn't mark as It is true that when a spec uses this feature it might become incompatible with another spec that also tries to enable these two types of implementations: you can't have a single document be expressed using two contexts that are in conflict with one another. Note that the Activity Streams work tried to enable simpler consumers too, it just didn't use the
Your concerns are certainly heard -- but it's important to remember that one of the constraints is that the simplest implementations do not use a JSON-LD library at all. To enable these implementations, document authors have to work within the constraints in the specification: you can't change certain term definitions in certain places. Simply allowing any definition to be used without throwing any errors won't solve this problem, it will just create semantic confusion. As always, myself (and many others) are all ears for a better solution to this problem (and given the constraints), but allowing semantic confusion to happen isn't an acceptable outcome -- so this is the best solution we've landed on for now. |
@trwnh wrote:
Hi, that's me ("whoever is responsible for controller/v1") :) It's a bug, thanks for catching it; that context is fairly new and hasn't been put through its paces yet. Feel free to raise a PR on controller/v1 to fix the issue, or I will do it when I get around to addressing the issue you raised in that repository. |
This is part of my concern, though: a document producer who does not use JSON-LD, but declares two well-known remote context documents, because the specs tell them to, or because they think that's what they need to do. What this producer has just done is completely invisible to "plain JSON" consumers (who aren't aware of any term definitions let alone the possibility of redefining one or that this might conflict). But even the most basic of JSON-LD processors now has to deal with the mess that was created by this incompatible context declaration. I'm not entirely convinced of the fail-fast-and-hard approach here; maybe the JSON-LD processing algorithm could use an additional flag that converts these errors to warnings? This would allow the processor to at least have something to process, provided that they are willing to accept the semantic confusion. (Any errors in schema would be caught "further down the chain", so the document may be discarded later if it is unsuitable for further processing.) Essentially, the use of |
This has been discussed before and identified as a really bad idea. What you describe is in the class of errors that can lead to security compromises. If you want to ignore these sorts of security compromises, don't use When this sort of thing happens (overriding errors of a detected term conflict), it is definitely a problem that must not be ignored. Doing so would be like a static analysis tool for a non-memory range checked language finding out that you're using memory after it has been freed and allowing the practice to continue happening -- it's a recipe for something really bad happening to the code in production. |
Okay, if you say To be clear, I think this kind of thing (where a certain interpretation is required) somewhat strongly indicates that perhaps In light of that, perhaps the use of |
This was discussed during the json-ld meeting on 13 November 2024. View the transcriptIssue Discussionbigbluehat: We're working through the project list. gkellogg: added issues that are class 1-3. subtopic w3c/json-ld-syntax#436 <gb> Issue 436 URI in Profile triggers CORS Unsafe Request Header Byte rule (by azaroth42) [spec:w3c] [needs discussion] [tag-needs-resolution] gkellogg: might just create "tokens" for profile paraemters. gkellogg: tokens not being namespaced is mitigated by the fact that the media-type is the namespace. bigbluehat: So, it treats the media-type as the namespace. gkellogg: not sure how we update guidance for using profile parameters. bigbluehat: This would be a breaking change for web annotations. niklasl: dlehn's reply may mean this isn't as horrible as it seems. pchampin: This doesn't seem to be a problem where things can't work, but making them work is tricky, due to pre-flight requests. <bigbluehat> q| pchampin: This is difficult to configure and easily forgotten. <gb> Issue 436 URI in Profile triggers CORS Unsafe Request Header Byte rule (by azaroth42) [spec:w3c] [needs discussion] [tag-needs-resolution] bigbluehat: There were some suggestions for defining enumerated values (tokens). <pchampin> I think it wouldn't hurt to define "short names" for the profiles in addition to the currently defined IRIs bigbluehat: The key is to not make it a breaking change. niklasl: Aren't link headers defined similarly, where there are pre-defined tokens and IRIs may also be used. bigbluehat: Browsers have made decisions which are affecting what we can do. <bigbluehat> > When processing the "profile" media type parameter, it is important to note that its value contains one or more URIs and not IRIs. In some cases it might therefore be necessary to convert between IRIs and URIs as specified in section 3 Relationship between IRIs and URIs of [RFC3987]. https://www.w3.org/TR/json-ld11/#iana-considerations <niklasl> application/ld+json;profile="http://iiif.io/api/presentation/3/context.json" niklasl: I think it would be good to add tokens. Rob's specific problem are more about the other uses of profiles. bigbluehat: The ramifications of this are not just expand/compact/... Rob's point is for other specifications that used the same pattern. <niklasl> See also: https://www.w3.org/TR/dx-prof-conneg/ (and https://profilenegotiation.github.io/I-D-Profile-Negotiation/I-D-Profile-Negotiation.html ) bigbluehat: There's reason to document this in the best-practices document. How this affects other specs would mean that they cannot treat profile as being extensible, and will need a new media type. gkellogg: we might create a registry to allow other specifications to add their profile parameters without needing a new media-type. bigbluehat: niklasl shared a document on using the profile parameter for content negotiation. pchampin: Reaching out the that TAG would be a good idea, as other specs rely on this, and they would be impacted. <niklasl> From the dx-prof-conneg draft: During 2018, DXWG members had a longer discussion with the JSON-LD WG at the annual forum TPAC in Lyon, France and it was concluded that the "profile” parameter in the Accept and Content-Type headers should be seen to convey profiles that are specific to the Media Type [such as JSON-LD's expanded .... ] pchampin: But, is there enough interest in IETF to continue the work? niklasl: There are aspects of the draft that goes into the profile parameter of the media type is the right way to go. <pchampin> https://www.w3.org/TR/vc-data-model-2.0/#media-type-precision pchampin: Regarding the value of using JSON-LD media-type with parameter vs a new media-type, VC has had to rely on this for a while. <niklasl> +1 to mentioning that "third" point of view (very pertinent IMHO) bigbluehat: I think we need to move on and come back to this issue. <bigbluehat> w3c/json-ld-syntax#443 <gb> Issue 443 `@protected` creates unresolvable conflicts when the same term is defined in two contexts top-level (by trwnh) [spec:editorial] [wr:commenter-agreed-partial] [class-2] |
This was discussed during the json-ld meeting on 13 November 2024. View the transcriptw3c/json-ld-syntax#443bigbluehat: This dove-tails with the profile-parameter conversation for other communities niklasl: IIRC, Activity Streams says you should put their context last because of this issue. dlehn: I need to re-review the issue. <niklasl> Maybe what is asked for is how to use this design pattern to have partial extensibility, extensions which are always subordinate to the "hardcoded" context (that may evolve)? dlehn: This would conflict with other things where JWT is also used. pchampin: The comment at the end is interesting as it resonates with TPAC discussions. bigbluehat: There's a tension between generic JSON-LD which is endlessly pluggable, which confuses people. <niklasl> +1 for best practice <anatoly-scherbakov> +1 <gkellogg> +1 dlehn: It seems to be a bit more than best-practices as you need to tell people how to get around the rules. dlehn: It's nice when things live together. bigbluehat: In the future, maybe there would be a way to link from the spec to BP. <bigbluehat> PROPOSAL: Address the concerns around when to use `@protected` (which were raised in #443 through new content in the JSON-LD Best Practices document. <gb> Issue 443 `@protected` creates unresolvable conflicts when the same term is defined in two contexts top-level (by trwnh) [spec:editorial] [wr:commenter-agreed-partial] [class-2] <bigbluehat> +1 <niklasl> +1 <pchampin> +1 <gkellogg> +1 <anatoly-scherbakov> +1 <TallTed> +1 <dlehn> +1 dlehn: Is it more "when" or "how" to use @Protected? RESOLUTION: Address the concerns around when to use `@protected` (which were raised in #443 through new content in the JSON-LD Best Practices document. bigbluehat: We can make it as "best practice" and notify the commenter. <niklasl> ... and *why* to... bigbluehat: @Protected needs more content. <dlehn> "... when, how, and why to use ..." |
I've just encountered issue #424 (and the related #361 as well) and in a similar situation with
https://www.w3.org/ns/controller/v1
definingalsoKnownAs
top-level alongside@protected: true
, whilehttps://www.w3.org/ns/activitystreams
definesalsoKnownAs
in a different namespace (as: vs sec:, loosely)From controller/v1:
From activitystreams:
Putting activitystreams before controller/v1 causes the later definition to override the older one, as expected (but not as desired):
But putting activitystreams after controller/v1 triggers the error due to
@protected: true
:JSON-LD 1.1 4.1.11 Protected term definitions https://www.w3.org/TR/json-ld11/#protected-term-definitions describes two exceptions. The first exception is when the definition is the same, which is not applicable here. The second exception is for property-scoped context definitions, which is unworkable because in this case the singular top-level object is intended to be both an Actor as well as a Controller Document.
To veryify, here's a type-scoped context definition that errors out:
And to reiterate, a property-scoped context definition can't be used because the
alsoKnownAs
property is top-level. So the way I see it, there's nothing that can be done to resolve this in a "plain JSON" compatible way except:@protected: true
alsoKnownAs
with the activitystreams-namespaced@id
instead of the security-namespaced oneThis leads me to think that
@protected
is a generally poorly-thought-out mechanism that highly increases the likelihood of such conflicts. Without it, as a producer I could just redefine the term later, for example by putting the activitystreams context last, or by using a local context object that comes after both remote contexts:or
I'm not sure the existence of
@protected
accomplishes its stated goal of "prevent[ing] this divergence of interpretation", nor that the rationale "that "plain JSON" implementations, relying on a given specification, will only traverse properties defined by that specification" is sufficiently addressing the issue of conflicts (or that it is a valid assumption in the first place). The issue arises when two specifications define the same term, and both specifications apply to the current object or document. It effectively leads to a hard incompatibility where it is impossible to implement both specs fully; you have to pick between them.If there's an option I'm not aware of I'd like to hear it.
The text was updated successfully, but these errors were encountered: