Skip to content

Feature request: include original error cause when throwing SetParameterError #3046

Closed
@dreamorosi

Description

@dreamorosi

Use case

When setting a parameter using the setParameter() function in the Parameters utility, Powertools for AWS can throw a SetParameterError if the underlying AWS SDK operation fails for any reason.

Currently the error being thrown is opaque and doesn't give any actionable info to customers on why the operation failed.

Since this is an error that we throw upon catching the underlying error, we should include the original error as cause of our own error.

Solution/User Experience

Once the feature is implemented, logging the error would result in this (excerpt of log):

{
  "error":{
      "name":"SetParameterError",
      "location":"file:///var/task/index.mjs:1317",
      "message":"Unable to set parameter with name /my-service/parameter",
      "stack":"SetParameterError: Unable to set parameter with name /my-service/parameter\n    at _SSMProvider.set (file:///var/task/index.mjs:1317:13)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Runtime.handler (file:///var/task/index.mjs:3477:5)",
      "cause":{
         "name":"ParameterAlreadyExists",
         "location":"/var/runtime/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js:7913",
         "message":"The parameter already exists. To overwrite this value, set the overwrite option in the request to true.",
         "stack":"ParameterAlreadyExists: The parameter already exists. To overwrite this value, set the overwrite option in the request to true.\n    at de_ParameterAlreadyExistsRes (/var/runtime/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js:7913:21)\n    at de_CommandError (/var/runtime/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js:6931:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20\n    at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/core/dist-cjs/index.js:165:18\n    at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38\n    at async file:///var/task/index.mjs:927:12\n    at async /var/runtime/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at async _SSMProvider.set (file:///var/task/index.mjs:1315:16)\n    at async Runtime.handler (file:///var/task/index.mjs:3477:5)"
      }
   }
}

Alternative solutions

No response

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparametersThis item relates to the Parameters Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions