Skip to content

improv(parameters): include cause in set parameter error #3047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Sep 11, 2024

Summary

Changes

Please provide a summary of what's being changed

This PR is a follow up to #3020 and brings a small DX improvement by including the cause of the error we throw when setting a parameter fails.

Before this PR, when the put parameter operation failed, we threw an opaque SetParameterError. Now, we include the original error from the AWS SDK as cause for an easier troubleshooting.

With this PR, the error would instead be:

{
  "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)"
      }
   }
}

While working on this, I also slightly improved the API docs for the new feature.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3046


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Sep 11, 2024
@dreamorosi dreamorosi requested a review from a team September 11, 2024 18:02
@dreamorosi dreamorosi requested a review from a team as a code owner September 11, 2024 18:02
@boring-cyborg boring-cyborg bot added the parameters This item relates to the Parameters Utility label Sep 11, 2024
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Sep 11, 2024
@github-actions github-actions bot added the enhancement PRs that introduce minor changes, usually to existing features label Sep 11, 2024
Copy link

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

APPROVED!

@dreamorosi dreamorosi merged commit ce9c7f0 into main Sep 12, 2024
12 checks passed
@dreamorosi dreamorosi deleted the improv/parameters_error_cause branch September 12, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that introduce minor changes, usually to existing features parameters This item relates to the Parameters Utility size/M PR between 30-99 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: include original error cause when throwing SetParameterError
2 participants