-
Notifications
You must be signed in to change notification settings - Fork 890
profiles: handling mismatch between content-type
and links.profile
list of profiles
#1359
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
Conversation
That's indeed a strong reason.
This seems like a pragmatic solution. But also somewhat confusing, because in the ideal case, the same information is present twice in the same response (once in the header, once in the body). In the less-than-ideal case, it'd be different. Perhaps we can at least ensure the ideal case by making a strong recommendation in the spec: recommending to compute the |
Given that the spec already (intends to) require that senders make the two lists of profiles identical, it feels a bit overboard to suggest that implementations meet that requirement in a particular way (e.g., by computing content-type from links), when they could just as reliably use some other strategy (e.g., compute links.profile from content-type). However, I do think it was a bit unclear that the spec was requiring these lists to be identical, so I've added a commit clarifying that. |
It may be valuable to explain the "why" in the new I think this is a step forward. Let's do this? 🚢 |
I'm feeling a bit swamped to think through the text of that right now, but would be totally open to a PR to that effect (either made directly to this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase, please
@dgeb should this be closed? |
Trying to help with some issue cleanup to help get 1.1 in release state.
|
Closing in favor of #1607, which addresses effectively the same issue for 1.1 in its current state. |
As @wimleers pointed out in his original review of #1268, we don't currently say what happens when a different list of profiles is specified in the document (in
links.profile
) than in theContent-Type
header.I've been thinking about a bunch of options and have concluded that the solution I offered in my original response to Wim's comment — i.e., making any mismatch trigger a 400 — is the wrong way to go. One issue with that solution is that it only covers documents sent to the server; i.e., it doesn't cover how the client should process documents sent from the server that have the same mismatch. (We could say that the client must entirely discard such responses... but I'm not sure clients would actually do that.) Another problem with the 400 approach — and actually any approach that requires the recipient to read both lists of profiles — is that it introduces a preprocessing step (e.g., to check that the lists match), and we have to pay the cost of that preprocessing step on every request, even though a mismatch should be a very rare event. That seems like a bad idea.
So, my preferred approach at this point, which is embodied in this PR, is simply to treat
links.profile
as the definitive list of applied profiles in the event of any mismatch. By treating one list as definitive, recipients can simply ignore the other (no comparison step required), but we can keep both in the spec, which is nice because both bring something of value. (Specifically, if we removed the parameter onContent-Type
, profile negotiation would look pretty asymmetrical; i.e., the client would use theprofile
parameter inAccept
, but not get it back in the response. Meanwhile,links.profile
is offering an elegant place to list profile aliases, which have to go in the document somewhere.)I chose to treat
links.profile
as the definitive source because recipients have to look there anyway before processing the document (to check for aliases), so making that the only place they have to look to determine the applied profiles seemed to make the most sense.Note: one small issue with making
links.profile
definitive is that the "missing a server-required profile error" from #1354 would probably have to be a 400 rather than a 415, because the required profile actually could be listed inContent-Type
but still be "missing" if its not listed inlinks.profile
. I think that's fine, but it means #1354 will have to be tweaked after this PR is merged.Note 2: Wim also pointed out that we don't say what should happen when the client lists a profile in the
profile
query parameter that isn't in itsAccept
header. But I think that case is already covered implicitly, and the answer is that the server should pay attention to the query parameter. That's because JSON:API says that theprofile
query parameter lists required profiles -- while both HTTP and JSON:API say that a profile can be applied to a response document even if it isn't in theAccept
header.