Follow-up to #2364011-173: [meta] External caches mix up response formats on URLs where content negotiation is in use

Parent issue closed but there are 2 todos

git grep 2364011
core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php:13: * @todo fix or replace this in https://www.drupal.org/node/2364011
core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:11: * @todo This is a temporary solution, remove this in https://www.drupal.org/node/2364011
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

added issues where that was introduced

btw 403/404 returns html render for REST endpoints and this is a bug

dawehner, is NegotiationMiddleware a temporary solution?
andypost: what do you think it should be replaced by?
dawehner, suppose proper content negotiation
andypost: well this will not happen atm.
dawehner, that's why I ask you, cos I see no issues in that direction
passing _format=json a bit annoying
yeah, it is...
that's not going to get fixed in 8.x though sadly
neclimdul, why?
because removing it would be an api change
it exists because we kinda steamrolled through the process of solving the problem to rush the release out
neclimdul, but there could be a contrib at least of sort of killswitch
and break other contrib?
you can manage middleware outside of core so i'm sure you can remove it and replace it with your own implementation
yep, but core needs issue
needs an issue for contrib managing middleware? that's something that has always existed
it takes time to dig why that works this way and a lot of people wondering
it works that way because reverse proxies and cdns have an akward arrangement of Vary implementations and feature sets
well the actual problems are the browsers
I mean that core could add new module and experiment
that was a problem that was solveable. it was CDNs that wasn't
or at least the problem we didn't solve
otoh that mostly affects rest endpoints so only cdn caching the issue
I was wondered that 403/404 for them returns html without _format passed
andypost: yeah that is a perfect usecase for that

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

naveenvalecha’s picture

Here's the intial patch. Assuming that the keeping the NegotiationMiddleware have a use case. So only removing the @todo atm. Not removing it due to B/C
//Naveen

20th’s picture

Title: Remove outdated @todo pointing https://www.drupal.org/node/2364011 » Remove outdated @todo pointing to #2364011
Category: Bug report » Task
Status: Needs review » Needs work

@naveenvalecha
You should remove both occurrences of the @todo comment because the referenced issue is closed for good.

@andypost
I wish you provided more details on when and how REST points return HTML. I did some quick manual testing and the format of the 404 pages was what I expected it to be. But that bug might have been already patched in the 8 months that passed since your comment.

naveenvalecha’s picture

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Status: Needs work » Closed (duplicate)
borisson_’s picture

The other issue only fixed this in RenderArrayNonHtmlSubscriber, not in the NegotiationMiddleware where the patch in #4 removes it from.

Should we reopen this issue and commit #4 or do we open a new issue to resolve this?

andypost’s picture

Version: 8.3.x-dev » 8.5.x-dev
Status: Closed (duplicate) » Needs review

Yes! patch from #4 exactly for that purpose

core8$ git grep 2364011
core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:11: * @todo This is a temporary solution, remove this in https://www.drupal.org/node/2364011
borisson_’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #4 still applies, so let's use that.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs subsystem maintainer review

Can we update or replace the @todo with whatever the current followup is (as described in #2)? We can't remove "temporary solutions" but we can deprecate them, so if we still think it's not-the-right-solution then we can file an issue for that.

The other alternative is "No actually, it's fine" in which case we can just remove it but tagging for subsystem maintainer feedback on whether the current API is actually what we want without any followup. :)

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bradjones1’s picture

Issue tags: +jsonapi

Tagging related to json:api as this service is actually used in a non-deprecated, very important sense in setting declaring the api_json format on requests. The proper Accept header for json:api is part of the upstream spec so I don't think this can go anywhere now, in that light? Since it's required by a core module?

Edited for a little clarity; the further I read it actually looks like the Accept header is part of the spec but not actively used in the negotiation; the request format is actually set by virtue of the route being accessed. Pretty clever. Regardless, though, it seems like this middleware probably can't go anywhere as the request formats have to be registered? So I think the todo would be good to go...

bradjones1’s picture

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

richardbporter’s picture

guilhermevp’s picture

There is only one of the todos remaining in 9.2.x to be removed in:

core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:11: * @todo This is a temporary solution, remove this in https://www.drupal.org/node/2364011

guilhermevp’s picture

Status: Needs work » Needs review
Abhijith S’s picture

FileSize
37.37 KB

Applied patch #24 and it removes the @todo from the file.

after

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larisse’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
33.15 KB
46.61 KB

Applied patch #23 and it removes the @todo from the file for me too.

guilhermevp’s picture

It's also applicable for 9.3.x.

alexpott’s picture

@Abhijith S @larisse thank you for looking into this issue.

Posting screenshots of your codebase or CLI does not advance the issue, since the automated testing infrastructure tells us whether the patch applies correctly.

So, I've removed the issue credit for that screenshot. In the future, you can get credit for issues by reading the issue to understand its purpose, and posting your review or testing of that purpose. Thank you!

See the issue credit guidelines for more information.

Crediting @bradjones1 and @andypost for comments on the issue.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Looking at #3028501: Enable header-based proactive content negotiation with optimizations and opt-outs available. - that's extending the functionality of this middleware - so it's not going anywhere and this @todo is definitely outdated.

@guilhermevp there was no need to a new patch - somewhat unbelievably #4 still applied. I'm not going to remove issue credit this time because of the length of time between patches but if a patch does apply then doing a review rather than a new patch upload is way better. Please don't upload exactly the same patch as a previous person.

Committed d523586 and pushed to 9.3.x. Thanks!

  • alexpott committed d523586 on 9.3.x
    Issue #2725435 by guilhermevp, naveenvalecha, andypost, bradjones1:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.