CLI-1729: Restore /translation API handling and _links removal logic in CLI#1962
CLI-1729: Restore /translation API handling and _links removal logic in CLI#1962danepowell merged 1 commit intoacquia:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores the special handling for /translation API endpoints that was unintentionally removed in a previous change. The restoration ensures that _links fields are stripped from translation API responses before being displayed to users, maintaining historical CLI behavior and preventing confusion.
Changes:
- Reintroduced conditional check for paths starting with
/translationinApiBaseCommand::execute() - Restored
mungeResponse()method to remove_linksfrom both top-level and nested response objects - Added comprehensive test coverage with four new test cases validating the
_linksremoval logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Command/Api/ApiBaseCommand.php | Restored the /translation path check and mungeResponse() method to strip _links fields from translation API responses |
| tests/phpunit/src/Commands/Api/ApiCommandTest.php | Added four new test cases covering various scenarios for _links removal logic including edge cases for path matching |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1962 +/- ##
=========================================
Coverage 92.28% 92.29%
- Complexity 1910 1916 +6
=========================================
Files 122 122
Lines 6987 6995 +8
=========================================
+ Hits 6448 6456 +8
Misses 539 539 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1962/acli.phar |
|
@jigar-shah-acquia, @danepowell: From the NCI viewpoint, this is a mistake. We can work with having the Also, I will note that the ACLI command |
|
I hear you James, thanks for the feedback. I've included it on our ongoing email threads and we'll get back to you there. Cheers. |
Motivation
This PR restores the special handling for
/translationAPI responses that was unintentionally removed in PR #1961 (CLI-1711).Previously, the CLI stripped
_linksfields from responses returned by/translationendpoints before displaying output to users. The removal of this logic caused_linksto reappear in CLI output, resulting in:Fixes #CLI-1729
Proposed changes
/translation.ApiBaseCommand::mungeResponse()to:_links_linkswithin response objectstestTranslationResponse()test.End-user impact
_linkswill no longer appear in CLI output for/translationendpoints.Alternatives considered
Leave
_linksin outputIntroduce a global
_linksstripping mechanism_linksare valid and expected in other API responses./translationendpoints.The chosen solution restores the original scoped behavior without impacting other commands.
Testing steps
acli.pharfor this PR.Run existing API commands unrelated to /translation (e.g., environment or site instance commands).
Verify _links fields are still present where previously expected.
Run full PHPUnit suite:
Confirm no unrelated test failures.
Execute a /translation API command.
Confirm:
_links are not displayed in CLI output.
Nested _links are also removed.
Run PHPUnit tests and verify:
Translation-specific test(s) pass.
Response formatting matches expected structure.