Skip to content

[Bug]: EasyPost SDK passes lowercase HTTP methods to Guzzle, triggering deprecation warnings since guzzlehttp/guzzle 7.11 #388

Description

@TripsCC

Software Version

8.7.0 (also reproducible on 8.8.0)

Language Version

PHP 8.1

Operating System

AWS Linux

What happened?

  1. Create an EasyPostClient and call $client->betaRate->retrieveStatelessRates($payload).
  2. With guzzlehttp/guzzle 7.11+, PHP emits an E_USER_DEPRECATED warning:
    "Passing a non-uppercase HTTP method to Client::request() is deprecated; guzzlehttp/guzzle 8.0 will preserve HTTP method casing."
  3. Stack trace points to EasyPost\Http\Requestor::requestRaw() calling $client->httpClient->request($method, ...), where $method is lowercase (e.g. 'post').
  4. BetaRateService::retrieveStatelessRates() calls Requestor::request($this->client, 'post', '/rates', ...).
  5. The API call still succeeds, but the deprecation is surfaced to the application (e.g. in CakePHP dev error output mixed into API responses).
  6. Reproduces on every EasyPost HTTP request that uses lowercase method strings across the SDK (post, get, put, delete, patch).

What was expected?

Requestor should pass uppercase HTTP methods (POST, GET, etc.) to Guzzle's Client::request() and Client::requestAsync(), or uppercase the method before delegating.

guzzle/guzzle@f050dce

Sample Code

<?php

use EasyPost\EasyPostClient;

$client = new EasyPostClient('EASYPOST_API_KEY');

$payload = [
    'to_address' => [
        'street1' => '417 Montgomery Street',
        'city' => 'San Francisco',
        'state' => 'CA',
        'zip' => '94104',
        'country' => 'US',
    ],
    'from_address' => [
        'street1' => '179 N Harbor Dr',
        'city' => 'Redondo Beach',
        'state' => 'CA',
        'zip' => '90277',
        'country' => 'US',
    ],
    'parcel' => [
        'length' => 10,
        'width' => 8,
        'height' => 4,
        'weight' => 15.4,
    ],
];

// Triggers deprecation with guzzlehttp/guzzle >= 7.11
$rates = $client->betaRate->retrieveStatelessRates($payload);

Relevant logs

Deprecated (16384): Since guzzlehttp/guzzle 7.11: Passing a non-uppercase HTTP method to Client::request() is deprecated; guzzlehttp/guzzle 8.0 will preserve HTTP method casing. Pass an uppercase method explicitly if uppercase is required.

Stack trace (abbreviated):
GuzzleHttp\Client::request() - guzzlehttp/guzzle/src/Client.php, line 223
EasyPost\Http\Requestor::requestRaw() - lib/EasyPost/Http/Requestor.php, line 185
EasyPost\Http\Requestor::request() - lib/EasyPost/Http/Requestor.php, line 111
EasyPost\Service\BetaRateService::retrieveStatelessRates() - lib/EasyPost/Service/BetaRateService.php, line 25

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssue is being researched

    Type

    No type

    Fields

    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