Big pipe cannot handle (GET) form redirects (EnforcedResponseException)

Created on 19 August 2022, over 2 years ago
Updated 14 February 2023, almost 2 years ago

Problem/Motivation

When a view with an exposed form (or another form using GET as #method) is being rendered using a lazy builder and that form throws a EnforcedResponseException (for example when the exposed form reset button is pressed), big pipe does not handle this exception; the redirect will not happen.

Steps to reproduce

Proposed resolution

Remaining tasks

Update issue summary
Write test
code review

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
BigPipeย  โ†’

Last updated 20 days ago

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands casey

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    For the tests in #4

    Also the issue summary should be updated to include proposed solution

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    We have noticed this issue is reproduce-able with the following setup:

    Views reference to eg let someone add a View Block to a node (BigPipe
    Views ajax history in place to make Views use 'GET'
    Better exposed filters enable Reset button
    Attempt to click the Reset button, and failure occurs

    Hoping to investigate and reproduce this well enough without a series of contrib modules, but for now hopefully this is at least somewhat helpful for others.

    The issue only occurs from Views Reference > beta4 as noted here https://www.drupal.org/project/viewsreference/issues/3380691 ๐Ÿ› Issue 2919092 breaks BC and causes issues for existing sites Needs review

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada efrainh

    Hi, I confirm this issue is happening when using Better exposed filters with the reset button + Views Reference Field 8.x-2.0-beta6.
    I tested the patch #3 and it kind of worked, but now when we press the Reset button, it redirects first to a URL with a query string and then to the page without the query string, so it reloads twice.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia AditiVB

    Aditi Saraf โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    @scott_euser Thank you! That's very helpful! Any chance you could write a test that reproduces this? ๐Ÿ™

    @efrainh Thank you! It's also very helpful to know that the patch in #3 is an incomplete fix.

  • Pipeline finished with Failed
    6 months ago
    Total: 261s
    #200911
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    scott_euser โ†’ changed the visibility of the branch 11.0.x to hidden.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser
  • Pipeline finished with Success
    6 months ago
    Total: 598s
    #200918
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Okay I need to work on reproducing this without Views Reference Field module, a bit down my queue though unfortunately.

    On the plus side, have managed to get a lot more test coverage into Views Reference Field module itself on (I assume everyone here is here because of some combination of that module and/or Views Ajax History) so hopefully welcome news!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Some progress adding a test, need to wait for ajax request, but out of time for today. Hopefully at least it gets someone going further on this (or hopefully I can come back to it soon enough)

  • Pipeline finished with Failed
    5 months ago
    Total: 531s
    #222751
  • Pipeline finished with Canceled
    5 months ago
    Total: 104s
    #227543
  • Pipeline finished with Failed
    5 months ago
    Total: 185s
    #227544
  • Pipeline finished with Success
    5 months ago
    #227553
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser
    1. Added test coverage
    2. Updated issue summary to standard template

    Ready for review

  • Status changed to RTBC 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Ran the test-only feature

    1) Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipe
    Behat\Mink\Exception\ExpectationException: The string "[{"command":"redirect","url":"\/big_pipe_test"}]" was not found anywhere in the HTML response of the current page.
    /builds/issue/drupal-3304746/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3304746/vendor/behat/mink/src/WebAssert.php:363
    /builds/issue/drupal-3304746/core/tests/Drupal/Tests/WebAssert.php:554
    /builds/issue/drupal-3304746/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php:226
    FAILURES!
    Tests: 4, Assertions: 153, Failures:
    

    Which shows the test coverage, yay!

    Issue summary appears complete and proposal to use a catch makes sense. Personally also like the use case added to the comment which really shows what this is getting.

    I believe this one should be good.

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    I guess you mean the ::checkRedirectUrl(), I guess we could:

    1. Break the method into two, so that the $response is handled in isolation as a separate method
    2. Optionally move that method into a new (or existing??) service

    So some sort of ::getSafeResponse() method somewhere and then ::checkRedirectUrl() becomes something like this semi-pseudo code?

      public function checkRedirectUrl(ResponseEvent $event) {
        $response = $event->getResponse();
        if ($response instanceof RedirectResponse) {
          $request = $event->getRequest();
          $event->setResponse(::getSafeResponse); <--- TBD where that method exists.
        }
      }
    

    In which case then bigpipe file here can also call ::getSafeResponse.

    Some other refactoring in the subscriber needed as well to make that happen, particularly if we move it elsewhere.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    If splitting it into a separate (existing??) service, should it be a separate child issue to this one, or okay to be in here?

  • Pipeline finished with Failed
    5 months ago
    Total: 179s
    #238724
  • Pipeline finished with Success
    5 months ago
    Total: 479s
    #238730
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Okay I left out the destination bit, was not sure whether that should be taken across too from RedirectResponseSubscriber::checkRedirectUrl() as it felt a bit like an additional feature and I could not quite think of a use case, but maybe I am wrong.

    I added test coverage for the new untrusted response expectation as well.

    Should I also be redirecting the untrusted response e.g. to the 403 route, or is just sending the MessageCommand okay? For now its just sending the message as I could not do a fully like for like reproduction of the RedirectResponseSubscriber::checkRedirectUrl(); specifically the 400 status.

    In any case, I think it covers the feedback relatively closely (with the notes above) so hopefully we are there or at least close to there with it.

    Thanks!

  • Status changed to RTBC 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Believe feedback has been addressed

  • Status changed to Downport 4 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Committed/pushed to 11.x and cherry-picked to 11.0.x, thanks!

    This doesn't cherry-pick cleanly to 10.4.x so moving there for backport.

    • catch โ†’ committed 0caccf51 on 11.0.x
      Issue #3304746 by scott_euser, casey, smustgrave: BigPipe cannot handle...
    • catch โ†’ committed ac0fac5e on 11.x
      Issue #3304746 by scott_euser, casey, smustgrave: BigPipe cannot handle...
  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 555s
    #303948
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    I did re-roll but it adding new properties to constructor so deprecation-mamba and change record are require improvement

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands casey

    Snapshot of latest state of MR for usage with composer-patches and D10.3.

  • Pipeline finished with Success
    about 1 month ago
    Total: 1192s
    #336836
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    rebased and now looks ready

  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Shouldn't we get into 10.5.x too?

    We got into 11.0, 11.1, current MR for 10.4.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    Patches for 10.5 and 10.4 are the same but I've created new MR

    This is a hard blocker for PHP 8.4

  • Pipeline finished with Success
    about 1 month ago
    Total: 395s
    #346099
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Re-roll seems good!

Production build 0.71.5 2024