AppConfig Custom Extensions Canceling Action

0

How do you properly cancel/error a deployment from a custom extension?

Documentation here: https://docs.aws.amazon.com/appconfig/latest/userguide/working-with-appconfig-extensions-creating-custom-extensions.html

States: "PRE_* action points can also respond to an error and prevent an action from happening."

But I can't seem to find ANY examples of how to do this properly.

In Node JS

return { error: 'string' }; // Lets the deployment continue

return { statusCode: 500 }: // Lets the deployment continue; it looks like AppConfig doesn't care what statusCode actually is, however its in ALL the examples (as 200, was thinking this was an HTTP error code)

return 'This is an error'; // Stops it, but return 'UnknownError: null' which doesn't really help

throw new Error('This is an error'); // Throwing an exception.. Stops it, but shows 'UnknownError: Error invoking extension testExtension: Unhandled error', also not meaningful

return { Content: 'This is an error' }; // Shows error 'UnknownError: Cannot deserialize value of type byte[] from String "This is an error": Illegal white space character (code 0x20) as character #3 of 4-char base64 unit: can only used between units at [Source: (byte[])"{"Content":"This is an error"}"; line: 1, column: 30] (through reference chain: com.amazon.awsblue.model.extensions.spi.Content["Content"]) ' ... while this does CONTAIN the error message the full error message is only due to the fact that Content is not base64-ed so the error being shown is the base64 decode error in AppConfig

jwalton
asked 2 months ago111 views
1 Answer
0

Based on the documentation, here are a few things to consider when returning errors from an AWS AppConfig extension:

Returning a generic error string like "This is an error" will cause the deployment to fail but may not provide useful information on the nature of the error.

Throwing an exception will also cause failure but the error message may not be clear.

Returning an object with an error property like {error: 'string'} allows the deployment to continue while signaling an error occurred.

The status code returned from an extension is not important as AppConfig does not actually handle HTTP responses. Status codes are used in examples but can be any value.

Returning structured error data as JSON may help provide more context, for example {message: 'Error message', details: 'Additional details'} .

Ensure any custom objects or types returned can be serialized properly to avoid unexpected errors being thrown.

profile picture
EXPERT
answered 2 months ago
  • return { message: 'Error message' } // AppConfig ignores and continues on return { error: { message: 'Error message' } } // AppConfig ignores and continues on return { Content: { message: "Error Message' } } // AppConfig errors with 'Unknown Error: null' return JSON.stringify({ message: 'Error message'}) // AppConfig errors with 'Unknown Error: null' return { error: JSON.stringify({ message: 'Error Message' }) } // AppConfig ignores and continues on return { Content: JSON.stringify({message: 'Error Message' }) } // AppConfig errors with Illegal white space character return { Content: Buffer.from(JSON.stringify({message: 'Error Message'}).toString('base64') } // AppConfig replaces my entire configuration with the error message, but doesn't error return Buffer.from(JSON.stringify({message: 'Error Message'}) Nothing even shows up in logs, and any structured data, that i've found, returned from extension is completely ignored except for the variable 'Content'. AppConfig just keeps deploying like nothing happened. If there is a structured way to send back an error message, I haven't found one. And there doesn't seem to be any documentation on it.

    I was hoping someone might know how to return a descriptive error message to the interface.

    I could throw an exception and print the error to logs... but i find that cumbersome to search through cloudwatch logs when the interface errors, just with an 'Unknown' error. Plus we have to give that user access to the logs for the extension..

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions