Closed (fixed)
Project:
JSON:API
Version:
8.x-2.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Nov 2018 at 07:13 UTC
Updated:
25 Dec 2018 at 11:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoSimple fix. I prefer this over detecting if the resource is internal because the route not existing is the real problem, the resource being internal is only one (the most common) of the possible explanations.
Comment #4
wim leersGreat catch!
Just one silly CS violation that caused it to not be green. Fixing, RTBC'ing, committing when it comes back green.
Comment #5
wim leersActually, leaving RTBC to let @gabsullice also +1 this approach.
Comment #6
gabesulliceI'm fine with a try/catch vs. detecting if the route is not defined. However, the promise of the
melink is mostly that it communicates the consumer's authentication state, i.e. the presence of themelinks tells the client that it is authenticated vs anonymous.I'd rather not remove this feature simply because the user is internal. I wonder if there's something else we could do...
Comment #7
gabesulliceHere's an alternative approach that won't break the signaling effect of
me, the link will just resolve to a 404.Comment #9
gabesulliceEasy fix.
Comment #10
e0ipsoI find that #7 will lead to confusion. As an API user I don't want to get links that don't exist. I don't think that people will disable the user resource type and be furious because the "me" link is missing.
I think that adding a "me" link that leads to a 404 is not the correct approach. We should not serve links that will always 404.
Comment #11
gabesulliceI agree that it's weird to point to a missing URL. I tried to think of something else, but nothing seemed cleaner (like a
nullhref or pointing to a different URL). This is the least disruptive change I could think of.The
melink has three functions, to point you to the resource that represents the current user, to indicate that the client is authenticated and to communicate the current user's UUID (so that you can filter to get a list "My Articles", for example). If we go with #4, we're killing all three of those functions. If we go with #7, we're only killing 1 of those functions.I'd ask, isn't it more confusing that the
melink disappears because you disabled the user resource type than it is for it to be404?If you follow the link and get a
404, I think it's a smaller mental leap to think "oh, it's 404 because I disabled the resource type" than it is when you're looking at themelink to see if you're authenticated and it's gone because you disabled a resource type.I think most developers in that scenario would start looking at their headers and cookies and such first, only to slap their head when they finally realize it's just because they made the user resource type internal.
In essence, I don't think that people will disable the user resource type and be furious because the "me" link is
missing404.Comment #12
e0ipsoI don't think so. I actually think it's expected.
When we disable a resource type, the link for that resource in the entry point disappears, that's what you expect. The "me" link is part of that resource, so it should disappear too.
I don't really see that happening. But if I did, I would argue that the same level of headscratching would happen due to a 404.
I think that manually constructing URLs (because there are no supporting routes) is a red flag.
Finally, remember that 4XX is a Client error. But in this case the client was not wrong, the server was.
Comment #13
wim leersWho's glad he didn't just go ahead and commit this? ✋
😃
I think it's a great point that this removes the ability to get the current client's
UserUUID, which is essential for certain operations (filtering to "my content"). Isn't that a concern of yours, @e0ipso?I suspect you think that if a particular site chooses to disable
User, that its data model and hence clients don't care about users/ownership at all?Comment #14
gabesullice@e0ipso, hmm, it seems we need to find a way that this won't throw an exception and end up in head-scratching.
What if we add a
meta.idmember to themelink object. So when the route is present we have:but when it's not, we have:
That's technically okay by the spec (but I really think only because of an oversight): "[A link object] can contain the following members [
href</code and <code>meta"Alternatively, we could change the
mestructure a little bit. Right now, it's a link undermeta, but it could be a resource object undermetainstead:Comment #15
wim leersInteresting proposals. I could live with either. I defer to @e0ipso to pick a direction. Or perhaps he has a different proposal still.
Comment #16
e0ipsoWe can have whatever data structure in meta, but I agree that a resource identifier object makes the most sense. However, note that this resource identifier will point to a non-existing resource…
I would like to not have a link to a 404 when the resource type is disabled and not to break the entry point.
Adding the blocker tag. This is blocking the adoption of 2.x by Contenta CMS.
I'll get a fix for this soon.
Comment #17
wim leers+1
Interesting! Is Contenta CMS disabling the
user--userresource type by default?Comment #18
e0ipsoYes. But even if it didn't, since we ship with JSON:API Extras enabled it'd be a blocker anyways.
Comment #19
wim leersHow does this issue and the "me" link in general relate to JSON:API Extras? It feels like I'm missing something here! 🤔
Comment #20
e0ipsoJSON:API Extras is the UI for disabling resources. However, that's not the main focus. I think we have to fix it regardless.
Comment #21
wim leersAhhhh, now I get what you meant! Thanks for clarifying :)
Comment #22
wim leers@e0ipso So, which in the proposals of #14 do you prefer?
Comment #23
e0ipso@Wim Leers I'm going to go with the first proposal of #14.
Comment #24
e0ipsoLet's kick off the tests.
Comment #26
e0ipsoI'm pretty sure the failures in #24 are due to a broken HEAD.
Comment #27
e0ipsoComment #28
wim leers#26: on it!
Comment #29
wim leers#3019389 has a green patch on 8.6 and 8.7, but a red one on 8.5, due to another commit having broken JSON:API in 8.5. Blocked on that.
In the mean time, this could already be reviewed by @gabesullice, who had strong opinions about this than I did I think.
Comment #30
gabesullice#24 LGTM. Thanks for pushing forward on this despite the frustration of a seemingly minor thing growing much bigger 🤗
RTBC, once all tests pass (this should happen when HEAD is unbroken).
Comment #31
wim leersYay!
Comment #32
wim leersBlockers have landed. Retesting.
Comment #34
wim leers