Skip to content

Cfn error code exceptions do not use error messages from the cause exception, omitting service level error messages and request Ids #243

Closed

Description

@aygold92

We created exceptions to represent the different error codes, specifically:

  • CfnAccessDeniedException
  • CfnAlreadyExistsException
  • CfnGeneralServiceException
  • CfnInternalFailureException
  • CfnInvalidCredentialsException
  • CfnInvalidRequestException
  • CfnNetworkFailureException
  • CfnNotFoundException
  • CfnNotStabilizedException
  • CfnNotUpdatableException
  • CfnResourceConflictException
  • CfnServiceInternalErrorException
  • CfnServiceLimitExceededException
  • CfnThrottlingException

The idea is that the handler would throw this exception, and the java plugin would convert that to a ProgressEvent with a FAILED status. However, these exceptions do not take error messages, which is required when there is a FAILED ProgressEvent.

Also, these exceptions should extend a common BaseErrorCodeException or somehting like that, so we can easily catch this. Handlers should not be throwing any other type of exception from their code.

Lastly, NotFound and AlreadyExists have duplicate exceptions, and I'm not sure what they are for:

  • ResourceNotFoundException and CfnNotFoundException
  • ResourceAlreadyExistsException and CfnAlreadyExistsException

Activity

  1. changed the title [-]Cfn error code exceptions do not take error messages[/-] [+]Cfn error code exceptions do not take error messages/are implemented incorrectly[/+] on Apr 17, 2020
  2. aygold92 commented on Apr 17, 2020

    @aygold92
    ContributorAuthor

    After doing a bit of digging it looks like we actually should use exception messages

    , but the constructors are pretty confusing and these messages never include AWS requestIds.

  3. aygold92 commented on Apr 17, 2020

    @aygold92
    ContributorAuthor

    it also looks we use BaseHandlerException which includes the ErrorCode

  4. aygold92 commented on Apr 17, 2020

    @aygold92
    ContributorAuthor

    it looks like really what the work is:

    1. improve exception messages from the BaseHandlerExceptions to include AWS error messages/requestIds
      Note: ResourceAlreadyExistsException actually extends CfnAlreadyExistsException and ResourceNotFoundException extends CfnNotFoundException, so again the issue is just we omit the service level exception message/requestId
      https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/src/main/java/software/amazon/cloudformation/exceptions/ResourceAlreadyExistsException.java
      https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/src/main/java/software/amazon/cloudformation/exceptions/ResourceNotFoundException.java
    2. add documentation that while it is required to return a progress event, handlers using the java plugin can throw a BaseHandlerException, which will be translated into a Progress Event by wrapper. This is the only acceptable exception to be thrown, otherwise they will see internal failure
    3. remove TerminalException https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/src/main/java/software/amazon/cloudformation/exceptions/TerminalException.java, which is not used or caught anywhere and is confusing
  5. changed the title [-]Cfn error code exceptions do not take error messages/are implemented incorrectly[/-] [+]Cfn error code exceptions do not use error messages[/+] on Apr 17, 2020
  6. changed the title [-]Cfn error code exceptions do not use error messages[/-] [+]Cfn error code exceptions do not use error messages from the cause, omitting service level error messages and request Ids[/+] on Apr 17, 2020
  7. changed the title [-]Cfn error code exceptions do not use error messages from the cause, omitting service level error messages and request Ids[/-] [+]Cfn error code exceptions do not use error messages from the cause exception, omitting service level error messages and request Ids[/+] on Apr 17, 2020
  8. added
    documentationI'll give you a guess what this is about.
    and removed
    bugSomething isn't working
    on Apr 17, 2020
  9. PatMyron commented on Aug 26, 2020

    @PatMyron
    Contributor

    Lastly, NotFound and AlreadyExists have duplicate exceptions, and I'm not sure what they are for:

    • ResourceNotFoundException and CfnNotFoundException
    • ResourceAlreadyExistsException and CfnAlreadyExistsException

    looks like these should be deprecated to avoid conflicts:

    * Uses for this exception class should delegate instead to
    * CfnNotFoundException. Many APIs use exception classes titled
    * ResourceNotFoundException, and if handler authors use this class, they'll
    * often need to use the fully qualified exception name.

    * Uses for this exception class should delegate instead to
    * CfnAlreadyExistsException. Many APIs use exception classes titled
    * ResourceAlreadyExistsException, and if handler authors use this class,
    * they'll often need to use the fully qualified exception name.

  10. wbingli commented on Sep 11, 2020

    @wbingli

    hmm, this issue should be fixed by #264

  11. ammokhov commented on Sep 22, 2020

    @ammokhov
    Contributor

    closing this issue as has been fixed by #264

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions