Automattic / vip-cli

The VIP-CLI
https://docs.wpvip.com/vip-cli/
MIT License
58 stars 17 forks source link

Use a more reliable way to convert to string #2059

Closed bor0 closed 1 month ago

bor0 commented 1 month ago

Description

Due to the recent MFA changes, my role was demoted to Member instead of Admin. When I tried to run vip @97.production config envvar get-all, the variables had the value of null, which caused the following error:

$ vip @97.production config envvar get-all
✕ Please contact VIP Support with the following information:
TypeError: Cannot read properties of null (reading 'toString')
    at /Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/lib/cli/format.js:75:50
    at Array.map (<anonymous>)
    at /Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/lib/cli/format.js:75:24
    at Array.forEach (<anonymous>)
    at table (/Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/lib/cli/format.js:74:8)
    at formatData (/Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/lib/cli/format.js:37:14)
    at getAllEnvVarsCommand (/Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/bin/vip-config-envvar-get-all.js:86:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _args.default.argv (/Users/bor0/.nvm/versions/node/v18.11.0/lib/node_modules/@automattic/vip/dist/lib/cli/command.js:461:11)
Error:  Unexpected error
Debug:  VIP-CLI v3.8.4, Node v18.11.0, darwin 24.0.0 arm64

Ideally, it should have returned something like this instead:

┌──────────────────────┬───────┐
│ name                 │ value │
├──────────────────────┼───────┤
│ AWS_S3_KEY_ADDONS    │ null  │
├──────────────────────┼───────┤
│ AWS_S3_SECRET_ADDONS │ null  │
...

This PR achieves that.

Pull request checklist

New release checklist

Steps to Test

  1. Check out trunk.
  2. Apply this test.patch
  3. Run vip @97.production config envvar get-all Expected: error should appear
  4. Switch to this branch
  5. Run vip @97.production config envvar get-all Expected: should be rendered properly
github-actions[bot] commented 1 month ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud