HTTP mock: Assets for the mocked responses are not stored if Guzzle throws an exception on error responses (4xx and 5xx)

Created on 23 June 2025, 10 days ago

Problem/Motivation

When generating asset files to store the HTTP call responses, if the response returns an error status (4xx and 5xx HTTP error codes), Guzzle throws an exception and stops processing other options from the HTTP Client options, which leads to skipping executing the handler that stores the response to the files.

Steps to reproduce

1. In the mode=store, make an outgoing HTTP call that returns an error, for example 401 error.
2. See that the assets file is not created.

Proposed resolution

Extend the first handler before the actual HTTP call to execute the next handler with a try-catch construction, and store the response on GuzzleHttp\Exception\BadResponseException.

🐛 Bug report
Status

Active

Version

1.5

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024