Skip to content

Commit bbff029

Browse files
committed
fix(AWS Local Invocation): Fix invalid result handling
1 parent 06c28e2 commit bbff029

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lib/plugins/aws/invokeLocal/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,17 @@ class AwsInvokeLocal {
799799
if (result instanceof Error) {
800800
handleError.call(this, result);
801801
return;
802-
} else if (result.headers && result.headers['Content-Type'] === 'application/json') {
802+
}
803+
try {
804+
JSON.stringify(result);
805+
} catch (error) {
806+
throw new ServerlessError(
807+
`Function returned invalid (not a JSON stringifiable) value: ${inspect(result)}`,
808+
'INVALID_INVOKE_LOCAL_RESULT'
809+
);
810+
}
811+
812+
if (result.headers && result.headers['Content-Type'] === 'application/json') {
803813
if (result.body) {
804814
try {
805815
Object.assign(result, {

0 commit comments

Comments
 (0)