IDE-1631: handled silent filure for gzip commands#1966
IDE-1631: handled silent filure for gzip commands#1966kalindi-adhiya wants to merge 4 commits intoacquia:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1966 +/- ##
=========================================
Coverage 92.29% 92.29%
Complexity 1916 1916
=========================================
Files 122 122
Lines 6995 6995
=========================================
Hits 6456 6456
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/1966/acli.phar |
There was a problem hiding this comment.
Pull request overview
This PR adds set -o pipefail to MySQL database import commands to prevent silent failures in shell pipelines. Previously, if commands like pv or gunzip failed in the pipeline, the overall command would still appear successful if the final mysql command succeeded, potentially leading to corrupted or incomplete database imports.
Changes:
- Added
set -o pipefail;prefix to both MySQL import command variants inPullCommandBase.php(with and withoutpv) - Updated test expectations in
PullCommandTestBase.phpto match the production code changes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Command/Pull/PullCommandBase.php | Added set -o pipefail; to MySQL import commands to catch pipeline failures |
| tests/phpunit/src/Commands/Pull/PullCommandTestBase.php | Updated test mock expectations to match the new command format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
tl;dr: looks good to me but I want @ashu-taide to approve as well since this is traditionally a brittle code path
This matches the pattern we already use for dumping the db, so it makes sense to do the same:
cli/src/Command/CommandBase.php
Line 2144 in db15ee6
Looks like we adopted that pattern in #1770 (CLI-1362) and failed to copy it here, presumably because we didn't expect the API to return invalid responses.
Problem Description
Previously, the MySQL database import commands in PullCommandBase.php used shell pipelines without proper error handling. In bash, by default, a pipeline only returns the exit status of the last command. This means if an earlier command in the pipeline fails (like pv or gunzip), but the final mysql command succeeds, the overall pipeline would still appear successful, potentially leading to silent failures during database imports.
Solution Details
Added set -o pipefail; prefix to both MySQL import command variants:
Error Scenarios Now Properly Handled
Success Flow After change