Conversation
The Coolify API rejects PATCH requests to services that include read-only fields (server_uuid, project_uuid, environment_name, environment_uuid, destination_uuid). The auto-generated API types include these fields as required, but they should not be sent on updates. This creates a custom ServiceUpdateRequest struct with only the mutable fields and uses UpdateServiceByUuidWithBody to send a custom JSON payload. Fixes 422 Unprocessable Content errors when updating services.
Owner
|
Thanks for the fix @juztim , looks good! I try to keep upstream API related fixes in the |
Author
|
I moved the service update fix into tools/overlay.yml so the generated UpdateServiceByUuid request body no longer includes the read-only fields, and docker_compose_raw stays required. Regenerated the OpenAPI client + provider code, then switched the service update call back to UpdateServiceByUuidWithResponse using the generated type. Commit: 8c245e3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 422 Unprocessable Content errors when updating
coolify_serviceresources.Problem
The Coolify API rejects PATCH requests to
/services/{uuid}that include read-only fields:server_uuidproject_uuidenvironment_nameenvironment_uuiddestination_uuidThe auto-generated
UpdateServiceByUuidJSONRequestBodyincludes these fields as required (notomitempty), causing every update to fail with:Solution
ServiceUpdateRequeststruct with only mutable fields (name,description,docker_compose_raw,instant_deploy)UpdateServiceByUuidWithBodyto send a custom JSON payload instead of the generated typeTesting
Tested against Coolify v4.x API - updates now succeed without 422 errors.