Skip to content

[BUG] listWebsiteFilesAndDirectoriesV1 throws TypeError on directories/symlinks because sizeBytes rejects null #6

Description

@tiolou

Bug: listWebsiteFilesAndDirectoriesV1 throws TypeError on directories/symlinks because sizeBytes rejects null

Description

HostingFilesApi::listWebsiteFilesAndDirectoriesV1() fails to deserialize its response whenever the listed directory contains a subdirectory, symlink, or any other non-file entry. The API correctly returns size_bytes: null for these entries, but the generated model rejects null at deserialization time.

Error

The type of the "sizeBytes" attribute for class "Hostinger\Model\HostingV1FilesFilesResourceItemsInner" must be one of "int" ("null" given).

Steps to reproduce

$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken($token);
$filesApi = new Hostinger\Api\HostingFilesApi(config: $config);

$filesApi->listWebsiteFilesAndDirectoriesV1(
    username: $username,
    domain: $domain,
    directory: ''
);
// Throws TypeError as soon as the document root contains any directory.

Root cause

In src/Model/HostingV1FilesFilesResourceItemsInner.php, the property is declared nullable and the setter accepts ?int, and its own docblock even documents this:

/**
 * @param int $sizeBytes Entry size in bytes. Null for directories, symlinks, and other non-file entries.
 */
public function setSizeBytes(?int $sizeBytes): self

However, the deserialization path (via ObjectSerializer) enforces a strict int-only type check against the OpenAPI type declared for this property, so it rejects the null the live API actually returns for non-file entries — contradicting the setter's own signature and docblock.

Expected behavior

Directories, symlinks, and other non-file entries should deserialize successfully with sizeBytes = null, consistent with the documented behavior and the nullable setter signature.

Suggested fix

Mark size_bytes as nullable: true in the OpenAPI spec for HostingV1FilesFilesResourceItemsInner, so the generated deserialization logic allows null — matching what setSizeBytes(?int $sizeBytes) already accepts.

Environment

  • Package: hostinger/api-php-sdk
  • PHP version: 8.1+
  • Endpoint affected: GET /api/hosting/v1/accounts/{username}/domains/{domain}/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions