Skip to content

Commit 2aebe83

Browse files
[dev] [Marfuen] mariano/fix-test-automation (#1574)
* chore(deps): update @AI-SDK packages and bump prisma binary targets * chore: enhance task automation with markdown reading and bot checks * chore(app): add PrismaPlugin to webpack configuration for server bundle * chore(app): re-enable .md imports as raw strings in webpack config * chore(app): add Turbopack configuration for .md file imports * chore(app): enable importing .md files as raw strings in webpack config * fix(secrets): implement form validation and submission for adding secrets * chore(app): add runtime configuration for long-running automation tasks * chore: replace S3Client instantiation with shared s3Client import * chore: add runtime configuration for lambda functions and update S3Client usage --------- Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent 0236b98 commit 2aebe83

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

apps/app/src/app/api/tasks-automations/lambda/invoke-with-logs/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';
22
import { Sandbox } from '@vercel/sandbox';
33
import { NextResponse } from 'next/server';
44

5+
export const runtime = 'nodejs';
6+
57
export async function POST(req: Request) {
68
try {
79
const { orgId, taskId, sandboxId } = await req.json();
@@ -23,7 +25,10 @@ export async function POST(req: Request) {
2325
: undefined;
2426

2527
// Invoke the Lambda
26-
const lambda = new LambdaClient({ region: 'us-east-1', credentials });
28+
const lambda = new LambdaClient({
29+
region: process.env.APP_AWS_REGION || 'us-east-1',
30+
credentials,
31+
});
2732
const invokeCommand = new InvokeCommand({
2833
FunctionName: 'automated-tasks',
2934
Payload: JSON.stringify({ orgId, taskId }),

apps/app/src/app/api/tasks-automations/lambda/invoke/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const DEFAULTS = {
88
taskId: 'tsk_689ce3dd6f19f4cf1f0ea061',
99
};
1010

11+
export const runtime = 'nodejs';
12+
1113
export async function POST(req: Request) {
1214
try {
1315
const body = (await req.json()) as {
@@ -29,7 +31,10 @@ export async function POST(req: Request) {
2931
}
3032
: undefined;
3133

32-
const lambda = new LambdaClient({ region, credentials });
34+
const lambda = new LambdaClient({
35+
region: region || process.env.APP_AWS_REGION || 'us-east-1',
36+
credentials,
37+
});
3338
const resp = await lambda.send(
3439
new InvokeCommand({
3540
FunctionName: functionName,

apps/app/src/app/api/tasks-automations/trigger/execute/route.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { s3Client } from '@/app/s3';
12
import { executeAutomationScript } from '@/jobs/tasks/automation/execute-script';
2-
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
3+
import { GetObjectCommand } from '@aws-sdk/client-s3';
34
import { NextResponse } from 'next/server';
45

5-
const s3 = new S3Client({ region: 'us-east-1' });
6+
export const runtime = 'nodejs';
67

78
export async function POST(req: Request) {
89
try {
@@ -14,9 +15,9 @@ export async function POST(req: Request) {
1415

1516
// Ensure the script exists in S3 before triggering the task
1617
try {
17-
const { Body } = await s3.send(
18+
const { Body } = await s3Client.send(
1819
new GetObjectCommand({
19-
Bucket: 'comp-testing-lambda-tasks',
20+
Bucket: process.env.TASKS_AUTOMATION_BUCKET || 'comp-testing-lambda-tasks',
2021
Key: `${orgId}/${taskId}.automation.js`,
2122
}),
2223
);
@@ -33,8 +34,6 @@ export async function POST(req: Request) {
3334
sandboxId,
3435
});
3536

36-
// In v4, we need to poll for the result or use a different pattern
37-
// For now, return the run ID and let the client poll for updates
3837
return NextResponse.json({
3938
success: true,
4039
runId: handle.id,

0 commit comments

Comments
 (0)