Skip to content

Commit 44e5d29

Browse files
authored
Detecting missing execution_metadata. (#4)
This 2 changes have massive influence on the success for snap-in rendering: 1. AI is taking the disclaimer literally and consequently reimplements runner code instead of using it. That's why the disclaimer needs to be removed from this code. 2. The check for missing execution_metadata is a good practice anyway and it prevents the server from stopping when such situation occurs. Work item: https://app.devrev.ai/devrev/works/ISS-188589
1 parent a1ab3e3 commit 44e5d29

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

base_folder/test/runner.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
/*
2-
* Copyright (c) 2024 DevRev Inc. All rights reserved.
3-
4-
Disclaimer:
5-
The code provided herein is intended solely for testing purposes.
6-
Under no circumstances should it be utilized in a production environment. Use of
7-
this code in live systems, production environments, or any situation where
8-
reliability and stability are critical is strongly discouraged. The code is
9-
provided as-is, without any warranties or guarantees of any kind, and the user
10-
assumes all risks associated with its use. It is the responsibility of the user
11-
to ensure that proper testing and validation procedures are carried out before
12-
deploying any code into production environments.
13-
*/
14-
151
import bodyParser from 'body-parser';
162
import express, { Express, Handler, Request, Response } from 'express';
173

@@ -111,6 +97,16 @@ async function handleEvent(events: any[], isAsync: boolean, resp: Response) {
11197

11298
for (let event of events) {
11399
let result;
100+
if (!event.execution_metadata) {
101+
let errMsg = 'Invalid request format: missing execution_metadata';
102+
error = {
103+
err_type: RuntimeErrorType.InvalidRequest,
104+
err_msg: errMsg,
105+
} as RuntimeError;
106+
console.error(error.err_msg);
107+
resp.status(400).send(errMsg);
108+
return;
109+
}
114110
const functionName: FunctionFactoryType = event.execution_metadata.function_name as FunctionFactoryType;
115111
if (functionName === undefined) {
116112
error = {

0 commit comments

Comments
 (0)