Skip to content

Commit 4106712

Browse files
bug #46293 [HttpClient] "debug" is missing if a request failed to even start (weaverryan)
This PR was squashed before being merged into the 6.1 branch. Discussion ---------- [HttpClient] "debug" is missing if a request failed to even start | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | none | Tickets | none | License | MIT | Doc PR | not needed If you do something really silly - like `$client->request('/foo')` (where no `base_uri` is configured), HttpClient correctly explodes with: > Invalid URL: scheme is missing in "/SymfonyCasts/vinyl-mixes/main/mixes.json". Did you forget to add "http(s)://"? However, in this situation, there will be no `debug` key in `$trace`. And so, currently on 6.1, instead of the above error, you see: > Warning: Undefined array key "debug" Let me know if any changes are needed. Thanks! Commits ------- 4beb320 [HttpClient] "debug" is missing if a request failed to even start
2 parents 8d5dd1b + 4beb320 commit 4106712

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ private function collectOnClient(TraceableHttpClient $client): array
171171

172172
private function getCurlCommand(array $trace): ?string
173173
{
174+
if (!isset($trace['info']['debug'])) {
175+
return null;
176+
}
177+
174178
$debug = explode("\n", $trace['info']['debug']);
175179
$url = $trace['url'];
176180
$command = ['curl', '--compressed'];

0 commit comments

Comments
 (0)