@friggframework/core 2.0.0--canary.627.33970be.0 → 2.0.0--canary.627.b5f8805.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -405,14 +405,28 @@ async function runPrismaMigrateResolve(migrationName, action = 'applied', verbos
405
405
  const [executable, ...executableArgs] = prismaBin.split(' ');
406
406
  const fullArgs = [...executableArgs, ...args];
407
407
 
408
+ // Pipe stdout/stderr so Prisma's actual failure reason (e.g. P3011
409
+ // "migration not found" from a mistyped name) is returned to the
410
+ // caller — not just left in CloudWatch. Still echo when verbose.
411
+ let stdout = '';
412
+ let stderr = '';
408
413
  const proc = spawn(executable, fullArgs, {
409
- stdio: 'inherit',
414
+ stdio: ['inherit', 'pipe', 'pipe'],
410
415
  env: {
411
416
  ...process.env,
412
417
  PRISMA_HIDE_UPDATE_MESSAGE: '1'
413
418
  }
414
419
  });
415
420
 
421
+ proc.stdout.on('data', (data) => {
422
+ stdout += data.toString();
423
+ if (verbose) process.stdout.write(data);
424
+ });
425
+ proc.stderr.on('data', (data) => {
426
+ stderr += data.toString();
427
+ if (verbose) process.stderr.write(data);
428
+ });
429
+
416
430
  proc.on('error', (error) => {
417
431
  resolve({
418
432
  success: false,
@@ -427,9 +441,12 @@ async function runPrismaMigrateResolve(migrationName, action = 'applied', verbos
427
441
  output: `Migration ${migrationName} marked as ${action}`
428
442
  });
429
443
  } else {
444
+ const detail = (stderr || stdout).trim();
430
445
  resolve({
431
446
  success: false,
432
- error: `Resolve process exited with code ${code}`
447
+ error: detail
448
+ ? `Prisma migrate resolve failed (exit ${code}): ${detail}`
449
+ : `Resolve process exited with code ${code}`
433
450
  });
434
451
  }
435
452
  });
@@ -31,7 +31,10 @@ const {
31
31
  ValidationError: GetValidationError,
32
32
  NotFoundError,
33
33
  } = require('../../database/use-cases/get-migration-status-use-case');
34
- const { LambdaInvoker } = require('../../database/adapters/lambda-invoker');
34
+ const {
35
+ LambdaInvoker,
36
+ LambdaInvocationError,
37
+ } = require('../../database/adapters/lambda-invoker');
35
38
  const {
36
39
  GetDatabaseStateViaWorkerUseCase,
37
40
  } = require('../../database/use-cases/get-database-state-via-worker-use-case');
@@ -262,6 +265,15 @@ router.post(
262
265
  });
263
266
  }
264
267
 
268
+ // Prisma migration name shape (<14-digit timestamp>_<name>). Rejects
269
+ // values that would be parsed as CLI flags (e.g. "--schema").
270
+ if (!/^\d{14}_[a-z0-9_]+$/i.test(migrationName)) {
271
+ return res.status(400).json({
272
+ success: false,
273
+ error: 'migrationName is not a valid migration identifier'
274
+ });
275
+ }
276
+
265
277
  if (!['applied', 'rolled-back'].includes(action)) {
266
278
  return res.status(400).json({
267
279
  success: false,
@@ -283,6 +295,16 @@ router.post(
283
295
  res.status(200).json(result);
284
296
  } catch (error) {
285
297
  console.error('Migration resolve failed:', error);
298
+ // Surface a worker-side 400 (bad input) as a 400, not a generic 500.
299
+ if (
300
+ error instanceof LambdaInvocationError &&
301
+ error.statusCode === 400
302
+ ) {
303
+ return res.status(400).json({
304
+ success: false,
305
+ error: error.message,
306
+ });
307
+ }
286
308
  return res.status(500).json({
287
309
  success: false,
288
310
  error: 'Failed to resolve migration',
@@ -204,6 +204,17 @@ exports.handler = async (event, context) => {
204
204
  body: { success: false, error: 'migrationName is required' },
205
205
  };
206
206
  }
207
+ // Prisma migration name shape (<14-digit timestamp>_<name>). Rejects
208
+ // values that would be parsed as CLI flags (e.g. "--schema").
209
+ if (!/^\d{14}_[a-z0-9_]+$/i.test(migrationName)) {
210
+ return {
211
+ statusCode: 400,
212
+ body: {
213
+ success: false,
214
+ error: 'migrationName is not a valid migration identifier',
215
+ },
216
+ };
217
+ }
207
218
  if (!['applied', 'rolled-back'].includes(resolveAction)) {
208
219
  return {
209
220
  statusCode: 400,
@@ -213,6 +224,15 @@ exports.handler = async (event, context) => {
213
224
  },
214
225
  };
215
226
  }
227
+ if (dbType !== 'postgresql') {
228
+ return {
229
+ statusCode: 400,
230
+ body: {
231
+ success: false,
232
+ error: `Migration resolve is only supported for postgresql, not "${dbType}"`,
233
+ },
234
+ };
235
+ }
216
236
 
217
237
  try {
218
238
  const result = await prismaRunner.runPrismaMigrateResolve(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.627.33970be.0",
4
+ "version": "2.0.0--canary.627.b5f8805.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -46,9 +46,9 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@friggframework/eslint-config": "2.0.0--canary.627.33970be.0",
50
- "@friggframework/prettier-config": "2.0.0--canary.627.33970be.0",
51
- "@friggframework/test": "2.0.0--canary.627.33970be.0",
49
+ "@friggframework/eslint-config": "2.0.0--canary.627.b5f8805.0",
50
+ "@friggframework/prettier-config": "2.0.0--canary.627.b5f8805.0",
51
+ "@friggframework/test": "2.0.0--canary.627.b5f8805.0",
52
52
  "@prisma/client": "^6.19.3",
53
53
  "@types/lodash": "4.17.15",
54
54
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -88,5 +88,5 @@
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  },
91
- "gitHead": "33970be6bc4ffa8e60d4c2799d6c24da4409bf5e"
91
+ "gitHead": "b5f8805cac1497009ffbc6278e74d1d9d62ca448"
92
92
  }