Skip to content

Libraries panel crashes when the cloud rejects a save #537

Open

Description

@rahulwalunje

Problem

If the cloud fails to create a library item, the plugin still answers the save request with HTTP 200 and an empty body, and the Libraries panel crashes with "There seems to be an error. Cannot read properties of undefined (reading 'labels')". The user gets no message about what went wrong, and the item is not saved.

Steps

  1. Run the cloud API with a small upload limit (PHP's default post_max_size of 8 MB reproduces it locally).
  2. In Assistant, open a library, choose Add Items, and add a long page so the upload with its screenshot exceeds the limit (18 MB when this was found).
  3. The request finishes, then the panel is replaced by the error.

Cause

  • CloudLibraries::create_item() reads $result->id without checking the response; a rejected upload decodes to null (PHP warning "Attempt to read property "id" on null" at backend/src/Clients/Cloud/CloudLibraries.php:26).
  • LibraryItemPostController::save_to_library() only treats success === false as an error, so a null response is returned as a success.
  • The UI then renders the missing item.

Expected

A failed or empty cloud response comes back as an error with a message the UI shows, and the panel stays usable.

Notes

Not caused by #519; found while testing it.

Activity

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