Skip to content

[Question, potentially a bug] How to debug requests when creating a server #403

Description

@BelleNottelling

Hi there, I'd appreciate some assistance on the following error that's produced by the SDK:

[09-Feb-2024 07:13:20 UTC] HTTP Error
~~~~~~~~~~
The remote server returned a "400 Bad Request" error for the following transaction:
 
Request
~~~~~~~
POST /compute/v2.1/servers HTTP/1.1
User-Agent: GuzzleHttp/7
Content-Type: application/json
Host: something
 
Response
~~~~~~~~
HTTP/1.1 400 Bad Request
Date: Fri, 09 Feb 2024 07:13:20 GMT
Server: Apache/2.4.52 (Ubuntu)
OpenStack-API-Version: compute 2.1
X-OpenStack-Nova-API-Version: 2.1
Vary: OpenStack-API-Version,X-OpenStack-Nova-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 137
x-openstack-request-id: something
x-compute-request-id: something else
Connection: close
 
Further information
~~~~~~~~~~~~~~~~~~~
Please ensure that your input values are valid and well-formed. Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging HTTP status codes, or file a support issue on https://github.com/php-opencloud/openstack/issues.

This error is produced with code as follows:

// Creates a new user on the OpenStack server and then establishes a new OpenStack connection instance using the new user's credentials.
$OpenStack = $this->authenticateAsClient();

// Now create a new network for the server to be attached to
$network = $OpenStack->networkingV2()->createNetwork([
    'name'         => "Some name",
    'adminStateUp' => true,
]);

// Finally create the server
$server = $OpenStack->computeV2()->createServer([
    'name'     => "Some name",
    'imageId'  => "The image ID",
    'flavorId' => "The flavor ID",
    'networks'  => [
        ['uuid' => $network->id]
    ],
]);

I am fairly new to OpenStack and I am working on a project with it, so I apologize if there's something I am blaitantly doing wrong here, but the logged message isn't particularly clear on what the problem is & searching "debug" on the docs returns no results.

Thanks!

Activity

  1. k0ka commented on Feb 9, 2024

    @k0ka
    Member

    Hello,

    1. you can get full request/response by passing additional options to the Openstack object. Like we do for debugging integration tests:
    $options = [
        'debugLog'         => true,
        'logger'           => new \OpenStack\Sample\DefaultLogger(),
        'messageFormatter' => new \GuzzleHttp\MessageFormatter(\GuzzleHttp\MessageFormatter::DEBUG),
        // .. auth options ...
    ];
    $openstack = new OpenStack($options);
    1. You can find official API documentation for this endpoint at https://docs.openstack.org/api-ref/compute/#create-server
  2. k0ka commented on Feb 9, 2024

    @k0ka
    Member

    What php memory limit do you have?
    It should output the full request/response body in the error by default:

    if (ini_get('memory_limit') < 0 || $message->getBody()->getSize() < ini_get('memory_limit')) {

  3. added a commit that references this issue on Feb 10, 2024
    ba2a215
  4. added a commit that references this issue on Feb 10, 2024
    38a6860
  5. k0ka commented on Feb 10, 2024

    @k0ka
    Member
  6. added a commit that references this issue on Jun 19, 2024
    baa4872
  7. added a commit that references this issue on Jun 12, 2025
    7104354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions