Skip to content

IDE-1631: handled silent filure for gzip commands#1966

Open
kalindi-adhiya wants to merge 4 commits intoacquia:mainfrom
kalindi-adhiya:CLI-1632-importdb
Open

IDE-1631: handled silent filure for gzip commands#1966
kalindi-adhiya wants to merge 4 commits intoacquia:mainfrom
kalindi-adhiya:CLI-1632-importdb

Conversation

@kalindi-adhiya
Copy link
Contributor

@kalindi-adhiya kalindi-adhiya commented Feb 19, 2026

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

  • File Access Issues: If the dump file is corrupted, missing, or unreadable by pv
  • Decompression Failures: If gunzip encounters a corrupted .gz file

Success Flow After change

./bin/acli pull:database 

 Select a Cloud Platform application: [Pipelines Examples]:
  [0] Pipelines Examples
  [1] DevX Canary - ACC (prod)
  [2] eekalindiadhiya
  [3] Acquia WIP Service
  [4] Anuj Kaushal (Employee Free)
  [5] Pipelines Validation 3: E2E testing
  [6] Pipelines UI Testing
  [7] Pipelines Validation: E2E testing
 > 2

Using Cloud Application eekalindiadhiya
 Choose a Cloud Platform environment [dev, dev (vcs: tags/2025-08-22)]:
  [0] dev, dev (vcs: tags/2025-08-22)
  [1] prod, prod (vcs: tags/2025-08-22.0)
  [2] RA, ra (vcs: master)
  [3] test, test (vcs: main)
 > 0

                                                                                                         
 [INFO] Using a database backup that is 23 hours old. Backup #341838528 was created at Wed Feb 18 7:42:01
        UTC 2026.                                                                                        
                                                                                                         
        You can view your backups here: https://cloud.acquia.com/a/environments/164759-727c3ab8-fb55-41c9-ba92-72d85f10b904/databases
                                                                                                         
        To generate a new backup, re-run this command with the --on-demand option.                       
                                                                                                         


    ✔ Downloading eekalindiadhiya database copy from the Cloud Platform
    ⠹ Importing eekalindiadhiya database download...
        Importing downloaded file to database drupal
                                                                                                         
 [WARNING] Install `pv` to see progress bar                                                              
    ✔ Importing eekalindiadhiya database download`

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (507381f) to head (1a70c87).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1966/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/1966/acli.phar
chmod +x acli.phar

@kalindi-adhiya kalindi-adhiya added the bug Something isn't working label Feb 19, 2026
@kalindi-adhiya kalindi-adhiya marked this pull request as ready for review February 19, 2026 08:13
Copilot AI review requested due to automatic review settings February 19, 2026 08:13
Copy link
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 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 in PullCommandBase.php (with and without pv)
  • Updated test expectations in PullCommandTestBase.php to 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.

Copy link
Contributor

@danepowell danepowell left a comment

Choose a reason for hiding this comment

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

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:

$command = 'bash -c "set -o pipefail; MYSQL_PWD="${:MYSQL_PASSWORD}" mysqldump --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}" | pv --rate --bytes | gzip -9 > "${:LOCAL_FILEPATH}""';

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.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants