Skip to content

Commit 7295289

Browse files
supabase sql update and lib files
1 parent ae83362 commit 7295289

File tree

12 files changed

+1253
-327
lines changed

12 files changed

+1253
-327
lines changed

app/api/sandbox/route.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// app/api/sandbox/route.ts - FIXED VERSION
21
import type { FragmentSchema } from "@/lib/schema"
32
import type { ExecutionResultInterpreter, ExecutionResultWeb } from "@/lib/types"
43
import { Sandbox } from "@e2b/code-interpreter"
4+
import templatesData from "@/lib/templates.json"
55

66
const sandboxTimeout = 10 * 60 * 1000 // 10 minutes in ms
77

@@ -218,6 +218,11 @@ function validateSandboxRequest(request: any): { valid: boolean; error?: string;
218218
return { valid: false, error: "Valid template is required", code: "INVALID_TEMPLATE" }
219219
}
220220

221+
// Validate template ID against known templates
222+
if (!Object.keys(templatesData).includes(fragment.template)) {
223+
return { valid: false, error: `Template '${fragment.template}' is not a valid template.`, code: "UNKNOWN_TEMPLATE" }
224+
}
225+
221226
// Validate files if present
222227
if (fragment.files && Array.isArray(fragment.files)) {
223228
for (let i = 0; i < fragment.files.length; i++) {
@@ -361,4 +366,4 @@ function getErrorStatus(error: any): number {
361366
if (message.includes("timeout")) return 408
362367

363368
return 500
364-
}
369+
}

0 commit comments

Comments
 (0)