Improve error handling for unreachable endpoints while using Remote Post handlers

Created on 28 September 2022, almost 2 years ago
Updated 22 April 2024, 2 months ago

Problem/Motivation

You may get the following error if you are trying to do a remote post to an unreachable endpoint.

TypeError: Argument 1 passed to Drupal\webform\Plugin\WebformHandler\RemotePostWebformHandler::getResponseData() must be an instance of Psr\Http\Message\ResponseInterface, null given

Steps to reproduce

1. Create new webform or edit an existing one.
2. Go to Settings > Emails / Handlers
3. Add new handler "Remote Post"
4. Fill out required fields in "General" tab
5. In the remote post url use http://serverdown.ouch/crazy-endpoint (to simulate an unreachable endpoint).
6. Save the handler.
7. Perform a test submission
8. You will see the error described above.

Proposed resolution

  • Add extra checks to handle the situation of having a NULL response from the remote post request
  • Addition of a new option in the Response status code select list (under the Custom response messages section)
  • Avoid calling to functions where the $response variable is required, for example in the getResponseData function

User interface changes

Add a new option 444 No Response into the Response status code select list under the Custom response messages section.

API changes

None.

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

πŸ‡―πŸ‡΅Japan eleonel Itoshima πŸ‡―πŸ‡΅

Live updates comments and jobs are added and updated live.
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.

Production build 0.69.0 2024