postgresdk 0.16.4 → 0.16.5
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.
- package/dist/cli.js +46 -10
- package/dist/index.js +46 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4704,14 +4704,25 @@ export async function createRecord(
|
|
|
4704
4704
|
|
|
4705
4705
|
log.debug("SQL:", text, "vals:", vals);
|
|
4706
4706
|
const { rows } = await ctx.pg.query(text, vals);
|
|
4707
|
-
|
|
4707
|
+
|
|
4708
4708
|
return { data: rows[0] ?? null, status: rows[0] ? 201 : 500 };
|
|
4709
4709
|
} catch (e: any) {
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4710
|
+
// Enhanced logging for JSON validation errors
|
|
4711
|
+
const errorMsg = e?.message ?? "";
|
|
4712
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
4713
|
+
|
|
4714
|
+
if (isJsonError) {
|
|
4715
|
+
log.error(\`POST \${ctx.table} - Invalid JSON input detected!\`);
|
|
4716
|
+
log.error("Input data that caused error:", JSON.stringify(data, null, 2));
|
|
4717
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
4718
|
+
} else {
|
|
4719
|
+
log.error(\`POST \${ctx.table} error:\`, e?.stack ?? e);
|
|
4720
|
+
}
|
|
4721
|
+
|
|
4722
|
+
return {
|
|
4723
|
+
error: e?.message ?? "Internal error",
|
|
4713
4724
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
4714
|
-
status: 500
|
|
4725
|
+
status: 500
|
|
4715
4726
|
};
|
|
4716
4727
|
}
|
|
4717
4728
|
}
|
|
@@ -5142,7 +5153,18 @@ export async function listRecords(
|
|
|
5142
5153
|
log.debug(\`LIST \${ctx.table} result: \${rows.length} rows, \${total} total, hasMore=\${hasMore}\`);
|
|
5143
5154
|
return metadata;
|
|
5144
5155
|
} catch (e: any) {
|
|
5145
|
-
|
|
5156
|
+
// Enhanced logging for JSON validation errors
|
|
5157
|
+
const errorMsg = e?.message ?? "";
|
|
5158
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
5159
|
+
|
|
5160
|
+
if (isJsonError) {
|
|
5161
|
+
log.error(\`LIST \${ctx.table} - Invalid JSON input detected in query!\`);
|
|
5162
|
+
log.error("WHERE clause:", JSON.stringify(params.where, null, 2));
|
|
5163
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
5164
|
+
} else {
|
|
5165
|
+
log.error(\`LIST \${ctx.table} error:\`, e?.stack ?? e);
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5146
5168
|
return {
|
|
5147
5169
|
error: e?.message ?? "Internal error",
|
|
5148
5170
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
@@ -5190,11 +5212,25 @@ export async function updateRecord(
|
|
|
5190
5212
|
|
|
5191
5213
|
return { data: rows[0], status: 200 };
|
|
5192
5214
|
} catch (e: any) {
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5215
|
+
// Enhanced logging for JSON validation errors
|
|
5216
|
+
const errorMsg = e?.message ?? "";
|
|
5217
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
5218
|
+
|
|
5219
|
+
if (isJsonError) {
|
|
5220
|
+
log.error(\`PATCH \${ctx.table} - Invalid JSON input detected!\`);
|
|
5221
|
+
log.error("Input data that caused error:", JSON.stringify(updateData, null, 2));
|
|
5222
|
+
log.error("Filtered data (sent to DB):", JSON.stringify(Object.fromEntries(
|
|
5223
|
+
Object.entries(updateData).filter(([k]) => !ctx.pkColumns.includes(k))
|
|
5224
|
+
), null, 2));
|
|
5225
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
5226
|
+
} else {
|
|
5227
|
+
log.error(\`PATCH \${ctx.table} error:\`, e?.stack ?? e);
|
|
5228
|
+
}
|
|
5229
|
+
|
|
5230
|
+
return {
|
|
5231
|
+
error: e?.message ?? "Internal error",
|
|
5196
5232
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
5197
|
-
status: 500
|
|
5233
|
+
status: 500
|
|
5198
5234
|
};
|
|
5199
5235
|
}
|
|
5200
5236
|
}
|
package/dist/index.js
CHANGED
|
@@ -3875,14 +3875,25 @@ export async function createRecord(
|
|
|
3875
3875
|
|
|
3876
3876
|
log.debug("SQL:", text, "vals:", vals);
|
|
3877
3877
|
const { rows } = await ctx.pg.query(text, vals);
|
|
3878
|
-
|
|
3878
|
+
|
|
3879
3879
|
return { data: rows[0] ?? null, status: rows[0] ? 201 : 500 };
|
|
3880
3880
|
} catch (e: any) {
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3881
|
+
// Enhanced logging for JSON validation errors
|
|
3882
|
+
const errorMsg = e?.message ?? "";
|
|
3883
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
3884
|
+
|
|
3885
|
+
if (isJsonError) {
|
|
3886
|
+
log.error(\`POST \${ctx.table} - Invalid JSON input detected!\`);
|
|
3887
|
+
log.error("Input data that caused error:", JSON.stringify(data, null, 2));
|
|
3888
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
3889
|
+
} else {
|
|
3890
|
+
log.error(\`POST \${ctx.table} error:\`, e?.stack ?? e);
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
return {
|
|
3894
|
+
error: e?.message ?? "Internal error",
|
|
3884
3895
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
3885
|
-
status: 500
|
|
3896
|
+
status: 500
|
|
3886
3897
|
};
|
|
3887
3898
|
}
|
|
3888
3899
|
}
|
|
@@ -4313,7 +4324,18 @@ export async function listRecords(
|
|
|
4313
4324
|
log.debug(\`LIST \${ctx.table} result: \${rows.length} rows, \${total} total, hasMore=\${hasMore}\`);
|
|
4314
4325
|
return metadata;
|
|
4315
4326
|
} catch (e: any) {
|
|
4316
|
-
|
|
4327
|
+
// Enhanced logging for JSON validation errors
|
|
4328
|
+
const errorMsg = e?.message ?? "";
|
|
4329
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
4330
|
+
|
|
4331
|
+
if (isJsonError) {
|
|
4332
|
+
log.error(\`LIST \${ctx.table} - Invalid JSON input detected in query!\`);
|
|
4333
|
+
log.error("WHERE clause:", JSON.stringify(params.where, null, 2));
|
|
4334
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
4335
|
+
} else {
|
|
4336
|
+
log.error(\`LIST \${ctx.table} error:\`, e?.stack ?? e);
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4317
4339
|
return {
|
|
4318
4340
|
error: e?.message ?? "Internal error",
|
|
4319
4341
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
@@ -4361,11 +4383,25 @@ export async function updateRecord(
|
|
|
4361
4383
|
|
|
4362
4384
|
return { data: rows[0], status: 200 };
|
|
4363
4385
|
} catch (e: any) {
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4386
|
+
// Enhanced logging for JSON validation errors
|
|
4387
|
+
const errorMsg = e?.message ?? "";
|
|
4388
|
+
const isJsonError = errorMsg.includes("invalid input syntax for type json");
|
|
4389
|
+
|
|
4390
|
+
if (isJsonError) {
|
|
4391
|
+
log.error(\`PATCH \${ctx.table} - Invalid JSON input detected!\`);
|
|
4392
|
+
log.error("Input data that caused error:", JSON.stringify(updateData, null, 2));
|
|
4393
|
+
log.error("Filtered data (sent to DB):", JSON.stringify(Object.fromEntries(
|
|
4394
|
+
Object.entries(updateData).filter(([k]) => !ctx.pkColumns.includes(k))
|
|
4395
|
+
), null, 2));
|
|
4396
|
+
log.error("PostgreSQL error:", errorMsg);
|
|
4397
|
+
} else {
|
|
4398
|
+
log.error(\`PATCH \${ctx.table} error:\`, e?.stack ?? e);
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4401
|
+
return {
|
|
4402
|
+
error: e?.message ?? "Internal error",
|
|
4367
4403
|
...(DEBUG ? { stack: e?.stack } : {}),
|
|
4368
|
-
status: 500
|
|
4404
|
+
status: 500
|
|
4369
4405
|
};
|
|
4370
4406
|
}
|
|
4371
4407
|
}
|