platformsh / platformsh-client-php

Platform.sh API client for PHP
https://platform.sh
MIT License
25 stars 27 forks source link

Developer Experience: Fetch and update of Project causes bad request #68

Open Kingdutch opened 2 years ago

Kingdutch commented 2 years ago

Problem

The below is a hickup in developer experience of the SDK. After writing it I realised that update is performing a PATCH and thus does not require all the data to be passed, but only the data that you actually wish to change.

I'm submitting this anyway because it's non-obvious when using just the SDK without actively looking at the docs and it may help someone else who was similarly puzzled.

Original Issue

The default_domain is a property of Project. Thus using the SDK I would expect to be able to update this property by:

  1. Fetching the project
  2. Getting the data for the project
  3. Adjusting the project
  4. Updating the project

However, in the current implementation this does not cause an error in the SDK. However it does cause a BadResponseException with a 400 Bad Request error from the server.

The API docs show that fetching provides a lot more info than is needed in updating which is probably the problem.

The checkProperty function could be used to flag this for a developer but it's currently not implemented for Project.