We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 06c28e2 commit bbff029Copy full SHA for bbff029
1 file changed
lib/plugins/aws/invokeLocal/index.js
@@ -799,7 +799,17 @@ class AwsInvokeLocal {
799
if (result instanceof Error) {
800
handleError.call(this, result);
801
return;
802
- } else if (result.headers && result.headers['Content-Type'] === 'application/json') {
+ }
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') {
813
if (result.body) {
814
try {
815
Object.assign(result, {
0 commit comments