-
Notifications
You must be signed in to change notification settings - Fork 2
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
Inconsistencies for transient entities handling in JSON format #1928
Comments
@falbert-ptc Thanks for reporting this, we will discuss it in one of the next OData TC meetings. |
Regarding use case #1 - recursive navigation between transient entities: I don't think we have a problem here because 11.2.5.2.1.1 Expand Option $levels only requires that services
Transient entities don't have an identity, so there can't be circles consisting only of transient entities. @falbert-ptc Do you have use cases for circular references involving transient entities? |
Regarding use case #2 - navigation links of transient entities: with 4.02 4.3 Transient Entities may have an explicit read URL, which means they also have default navigation links (read URL plus navigation segment). If they don't have a read URL, they may have explicit navigation links. @falbert-ptc: Do you have use cases for transient entities with navigation links? |
We do have use cases with circular references between transient entities. We have an endpoint that returns structured data (parent-child relationship) of transient entities. Each transient entity represent an information aggregate of multiple data sources, and cannot be addressed individually outside of the current response. Each transient entity has multiple navigations to said data sources. While rare, there are cases where there could be circular references (direct or indirect) between an ascendant and a descendant in the structure. The issue is with the JSON format, where transient entities are specifically stated to not have an entity id. So it's impossible to have an entity reference or a read URL + navigation segment. Note that in my research I've only looked at 4.0 and 4.01. I wasn't aware that 4.02 had been published. Although, I did not find any update to the JSON format in 4.02 (https://docs.oasis-open.org/odata/odata/v4.02/). |
@falbert-ptc Thanks for the explanation! How would you recognize circular references between transient entities? Do these entities have an internal id that you can use to determine whether two of them are really the same and not just coincidentally have the same representation? |
With XML, do you mean the OData Atom Format Version 4.0? If yes, do you use this in "production" software? |
Correct. That way, the client can use those unique ID when finding an entity reference. |
Yes, that's what I meant. |
Could you use this to construct a non-canonical URI to use in the That way you could use entity references to express cycles within a response. |
Did you encounter any gaps in the Atom format? |
Yes, that would be the easiest and preferred way. |
Which (kind of) client (software/app) did stumble over this, and how could they figure out that the entities were transient? I'd like to know how much chaos we may cause if we relax the specification and allow "temporary" or unresolvable URIs in addition to |
What we're finding challenging with Atom is that there are less examples, or examples are a lot more abstract (as opposed to the Order/Customer/etc. examples). One use case that comes to mind is action invocation: we found it hard to understand the correct way to pass action parameters in the request body. Because this is not a widely requested feature, our investment has mostly been on the JSON format. |
With 4.02 we explicitly allow transient entities to have read URLs, which means they also can have default computed navigation links that can be omitted from the payload. This of course requires the service to correctly answer requests to Already with 4.0 it was possible to have explicit navigation links in transient entities, if one doesn't mind the resulting verbosity of the JSON responses. |
Honestly, I do not remember the specifics. I think the problem of an unresolvable URI exists today in the Atom format because it always includes the entity id.
But, if the entity id is in the specific "odata:transient:" format, then the client would know that it is not resolvable. |
Another way to say this is: if I could reuse the same generated transient ID in both XML and JSON, that would resolve all our problems :). |
@falbert-ptc Please check & review PR #1942 |
@falbert-ptc after discussing this in the Technical Committee we came up with a new proposal: use Entity references already can contain instance annotations, so having an entity reference of the form {
"@context": "http://host/service/$metadata#$ref",
"@id": null,
"@Core.ContentID": "some-value-already-used-in-this-response"
} would be allowed already. Would that solve your problem? |
Hi @ralfhandl Are you suggesting to use this instance annotation in the response to any type of request, not just deep insert or deep update ? It would also make this annotation essentially mandatory, since you cannot predict whether a particular transient entity will be found again in the payload. It is also unclear how that would work in the Atom XML format. The Atom format always contains an id with a value (whether the entity is transient or not). Is that annotation supposed to supersede the id ? What should the client use (and if they have different values) ? Thank you |
Hi @falbert-ptc,
It would make the This means
In this case the service can
Which of these options would work for your use case? |
Hi @ralfhandl From a client perspective, it means it would now be expected for a client to find and process this annotation in the response since a client cannot know in advance if the resulting entities are transient (no way to know from the EDM), nor if there will be circular references. Another way to say this is that for the JSON format, if the id is null, the client is expected to find and process this Core.ContentID annotation to be able to interpret circular references in nested entities. For the Atom XML format, client can use the entity id or this annotation, assuming they have an identical value (which for now is a pretty big assumption). This also adds new use cases for this annotation, which up until now was optional and only for deep insert use cases. Additionally, like I said before, there is currently no mechanism for the client to know if an entity is transient and if they have to process this annotation or not. It means, any client will have to always look for this annotation. This is also a bit inconsistent with the statement about resolving circular dependencies with entity references, since an entity reference MAY have an annotation, but is not required to. And the current definition of the entity reference does not specify this annotation as being a core/required element of what identifies an entity (albeit transient). Finally, it's also unclear how the annotation would work in the Atom XML format. TL;DR:
|
Next idea:
Cases
@falbert-ptc Would that work for you? |
Hi @ralfhandl , |
- [x] Fixes #1928 - [x] Align with Protocol (transient entities may have a read URL) - [x] Adjusted Protocol (transient entities may have an entity id) --------- Co-authored-by: Heiko Theißen <[email protected]>
Both 4.0 and 4.01 seems to have inconsistencies regarding handling of transient entities in the JSON format.
Null ID for transient entities in JSON:
However, it seems to be incompatible with at least 2 other use cases:
In the case of the XML format, this is not an issue since even transient entities have an id. The client can use those transient ids when parsing and make sense of the references.
The text was updated successfully, but these errors were encountered: