rockcarver / frodo-cli

A CLI to manage ForgeRock platform deployments supporting Identity Cloud tenants, ForgeOps deployments, and classic deployments.
MIT License
17 stars 16 forks source link

Better error handling during `frodo saml export` #192

Closed vscheuber closed 1 year ago

vscheuber commented 1 year ago

Describe the solution you'd like

When frodo encounters errors during the export of a saml provider it should describe the error as closely as possible, when exporting all providers (-a or -A) it should report the error and continue on.

See an example where the metadata of a provider cannot be retrieved and frodo reports a meaningless error:

% frodo saml export -A volker-dev
Connected to https://openam-volker-dev.forgeblocks.com/am [alpha] as user volker.scheuber@forgerock.com
[=============---------------------------] 33% | 1/3 | Exporting provider darinder-demonode:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received nu
    at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
    at new NodeError (node:internal/errors:387:5)
    at Function.from (node:buffer:328:9)
    at enc (file:///Users/vscheuber/Projects/frodo-lib/esm/api/utils/Base64.mjs:40:46)
    at exportDependencies (file:///Users/vscheuber/Projects/frodo-lib/esm/ops/Saml2Ops.mjs:90:74)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exportSaml2Provider (file:///Users/vscheuber/Projects/frodo-lib/esm/ops/Saml2Ops.mjs:179:3)
    at exportSaml2ProvidersToFiles (/Users/vscheuber/Projects/frodo-cli/esm/ops/ops/Saml2Ops.ts:233:24)
    at FrodoCommand.<anonymous> (/Users/vscheuber/Projects/frodo-cli/esm/cli/saml/cli/saml/saml-export.ts:88:11) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v18.7.0