Skip to content

fix(env:deploy:type): update settings via direct PATCH#94

Open
pjcdawkins wants to merge 1 commit into
mainfrom
fix/env-deploy-type-settings-edit
Open

fix(env:deploy:type): update settings via direct PATCH#94
pjcdawkins wants to merge 1 commit into
mainfrom
fix/env-deploy-type-settings-edit

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

Problem

env:deploy:type <type> fails with Operation not available: edit:

In ApiResourceBase.php line 306:
  [Platformsh\Client\Exception\OperationUnavailableException]
  Operation not available: edit

The command set the deployment type with $settings->update(), which runs the client's edit operation. That operation requires an #edit HAL link on the /settings resource, but the API only returns a self link:

{ "id": "settings", "_links": { "self": {"href": ".../settings"} }, "enable_manual_deployments": false }

So operationAvailable('edit') was always false and the update threw before sending any PATCH.

This was a regression introduced when the command switched from $environment->setManualDeployments() to $settings->update().

Fix

Replace the update() call with a direct PATCH request to the settings endpoint, wrapping the response in a Result so the existing activity-wait path is unchanged.

Tests

The TestEnvironmentDeployType integration test previously passed only because the mock API fabricated an #edit link that the real API never sends. The mock's /settings response is corrected to return only self, matching production, so the test now exercises the failing path. With the fix, the full integration suite passes.

🤖 Generated with Claude Code

The command set the deployment type with $settings->update(), which runs
the client's "edit" operation. That operation requires an "#edit" HAL link
on the /settings resource, but the API only returns a "self" link, so the
command failed with "Operation not available: edit".

This was introduced when the command switched from
$environment->setManualDeployments() to $settings->update(). Replace the
update() call with a direct PATCH request to the settings endpoint.

The mock API's /settings response previously included a fabricated "#edit"
link, hiding the regression. Remove it so the mock matches the real API,
and the integration test now exercises the failing path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 26, 2026 23:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a regression in the legacy environment:deploy:type command where updating environment deployment settings failed because the /settings resource does not advertise an #edit HAL link, causing the client’s update() path to throw before issuing any PATCH request.

Changes:

  • Update environment:deploy:type to PATCH the settings endpoint directly and wrap the response in a Result to preserve the existing activity-wait flow.
  • Adjust the mock API’s environment settings resource to only expose a self link (matching production behavior), removing the fabricated #edit link.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/mockapi/environments.go Aligns mock /settings HAL links with production (self-only), ensuring tests exercise the real failure mode.
legacy/src/Command/Environment/EnvironmentDeployTypeCommand.php Switches from $settings->update() to a direct PATCH and wraps the response in Result to keep activity waiting behavior consistent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants