Skip to content

Fix ChecksClient.logError() type safety (hasResponse on GuzzleException) #51

@jordanpartridge

Description

@jordanpartridge

Context

app/GitHub/ChecksClient.php line 245 calls \$e->hasResponse() on a GuzzleException typed parameter. The hasResponse() method only exists on GuzzleHttp\Exception\RequestException, not on the GuzzleException interface.

The bug

private function logError(string \$method, GuzzleException \$e): void
{
    echo "::error::GitHub API error in {\$method}: {\$e->getMessage()}\n";

    if (\$e->hasResponse()) {  // <-- hasResponse() not on GuzzleException interface

Fix

Add an instanceof check:

private function logError(string \$method, GuzzleException \$e): void
{
    echo "::error::GitHub API error in {\$method}: {\$e->getMessage()}\n";

    if (\$e instanceof \GuzzleHttp\Exception\RequestException && \$e->hasResponse()) {

Acceptance

  • PHPStan level 6+ passes without type errors on this method
  • Existing ChecksClient tests still pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyReady for autonomous agent executionbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions