Discovered while working on #2930028: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only. See #2930028-21: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only. Needs to be investigated.
The spec permits this: http://jsonapi.org/format/#crud-creating-client-ids
Let's discuss the pros/cons.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2934386-20.patch | 7.26 KB | gabesullice |
| #20 | interdiff-2934386-20.txt | 807 bytes | gabesullice |
| #17 | 2934386-17.patch | 7.12 KB | gabesullice |
| #17 | interdiff-2934386-17.txt | 3.82 KB | gabesullice |
Comments
Comment #2
wim leersComment #3
gabesulliceComment #5
gabesulliceMaking this a feature request. It looks like this was an intentional omission.
Comment #6
wim leersTwo things:
Entityobject whose values match those of A) the stored entity, B) the JSON API representation.Intentionally ignoring the provided ID/UUID when
POSTing is independent of that!That's actually not true: see #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002). I didn't know that either until somebody filed that issue and Entity API maintainer @tstoeckler spoke up!
Comment #7
gabesulliceFWIW, not supporting client-generated UUIDs, we make offline use cases much more difficult.
I'm not sure I understand the 1/7 likelihood of collisions.
Checking for collisions seems like a reasonable price to pay to permit offline/asynchronous creation of entities or synchronization between sites which use UUIDs (like the Entity Share module).
Comment #8
gabesulliceComment #9
wim leersRight, it'll be likely necessary for use cases with offline content creation and absolutely be a requirement for supporting Workflow Initiative-related use cases.
Comment #10
grimreaperHello,
Thanks @gabesullice for pinging me.
As I am not sure if the "client-generated UUIDs" is in a GET or a POST request, I will recap the needs for the Entity Share module:
Comment #11
e0ipsoLOL. Gabe, come on, you know me. That was a joke. It was a snarky way to say that I don't trust consumers to submit uuids without collisions.
My honest thoughts around this are:
Beach developer speaking: that's a formality that I don't think gives us anything in return, so … meh. Again, you can't provide an
nid, but the deserialized entity will eventually get one. As usual, I don't think that the current state harms us (wrt the serialization formality), but the proposal either. So I'm not opposed to the change.I am slightly horrified by that, but I admit that I won't discuss that there can be use cases for that.
Well, that's hard to quantify. UUIDs will need to be checked against all entity types possible. Not the end of the world but I'm not dismissing the impact as easily.
Quoting myself here, mum would be proud. There are ample reasons here that make me go from unsure about the value to yeah, that's pretty useful.
TL;DR I agree with the majority, let's do this. I don't think this is necessarily high priority (it's a feature request), but when we get to it let's follow http://jsonapi.org/format/#crud-creating-client-ids to the letter.
Comment #12
wim leers:D
+1
Comment #13
wim leersRetitling to match http://jsonapi.org/format/#crud-creating-client-ids's wording.
Comment #14
e0ipsoIncreasing priority on this one.
Comment #15
gabesulliceComment #16
wim leersThis doesn't seem like it should be a 403, but a 422?
It also reads strangely.
This is now sending a UUID field in every "denormalize" test case. Which means we're losing test coverage, because sending this is not required, it's optional.
Comment #17
gabesulliceI agree, but to follow the spec "to the letter" (#10), that's what we have to respond with.
Fixed the wording :)
That's not quite accurate. The input data has always had UUIDs under
$input['data']['id']in every case. These additions are just asserting that, yes, indeed those input IDs are being properly used as theuuidvalue before denormalizing into an actual entity.Regardless, you're right, we should be testing both cases and I've added coverage for it to the
testDenormalizeUuidmethod.Comment #18
wim leersOh! That seems like a bug in the spec, but oh well. Can we then add a comment like:
I personally prefer
I find that more legible. Learned it from a fellow core developer, don't know who :)
Just leave this, it's an insane nit, and it's not defined in the coding standards. Just wondering if you simply prefer what you wrote, or were unaware of this alternative? :)
Comment #19
wim leersOops, NW for that first nit, to help our future selves.
Comment #20
gabesulliceAdded the comment because it is an easy thing to get tripped up on.
As for the spec bug, I really think you can debate it either way. It could easily be that trusted clients are permitted to generate UUIDs while others are not, which would make the 403 correct. And it's not "semantically" incorrect to provide a UUID in those cases.
I really do prefer it my way :P yours feels like putting an opening curly brace on its own line (/me shudders) :P It's says, this statement is not over, it's not missing a semicolon. But this is definitely a bike shed situation.
Comment #21
wim leers🚲 🎨 💥
Comment #23
wim leersI felt safe committing this, because @e0ipso wrote:
Comment #24
wim leersThe regression in core in this same area was also fixed ~2 weeks ago btw: #2885469: Regression: manually setting the ID field for newly-created content entities is not possible anymore (public follow-up to SA-2017-002) :)
Comment #25
e0ipsoWRT to the ternary operator, I favor the question mark at the beginning. That's how linters want it in node.js land so I've grown to like it.
Comment #26
wim leersFollow-up created: #2942243: Follow-up for #2934386: server-generated IDs for newly POSTed entities should not be exposed in 403 responses.