Skip to content

Commit 3e74246

Browse files
committed
fixes
1 parent 5a6828a commit 3e74246

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

js/botasaurus-server-js/src/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function removeDuplicatesByKey(dictList: any[], key: string): any[] {
9797
const seen = new Set();
9898
const newDictList: any[] = [];
9999
for (const d of dictList) {
100-
if (key in d) {
100+
if (key in d && !isNullish(d[key])) {
101101
if (!seen.has(d[key])) {
102102
seen.add(d[key]);
103103
newDictList.push(d);

js/botasaurus-server-js/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type WhatsAppSupportOptions = {
4848
countryCallingCode: string; // Country calling code (e.g., 81 for Japan, 1 for the US)
4949
message: string; // Default message for WhatsApp
5050
};
51+
5152
/**
5253
* Replaces FileTypes constants (e.g., FileTypes.IMAGE) in a string of code
5354
* with their corresponding JSON array values.

js/botasaurus-server-js/src/validation.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,15 @@ export function validateAndGetTaskId(id: any): number {
316316
}
317317

318318
if (isStringOfAtLeast1Len(id)) {
319-
320-
id = tryIntConversion(id, "Task id is invalid");
319+
const idStr = isObject(id) ? JSON.stringify(id) : id;
320+
id = tryIntConversion(id, `Task id '${idStr}' is invalid.`);
321321

322322
}
323323

324324

325325
if (!isValidId(id)) {
326-
throw new JsonHTTPResponseWithMessage("Task id is invalid");
326+
const idStr = isObject(id) ? JSON.stringify(id) : id;
327+
throw new JsonHTTPResponseWithMessage(`Task id '${idStr}' is invalid.`);
327328
}
328329

329330
return id;
@@ -340,7 +341,8 @@ export function validatePatchTask(jsonData: any): number[] {
340341
}
341342

342343
if (!isListOfValidIds(taskIds)) {
343-
throw new JsonHTTPResponseWithMessage("'task_ids' must be a list of integers");
344+
const taskIdsStr = isObject(taskIds) || Array.isArray(taskIds) ? JSON.stringify(taskIds) : taskIds;
345+
throw new JsonHTTPResponseWithMessage(`'task_ids' with value '${taskIdsStr}' must be a list of integers representing scraping task ids.`);
344346
}
345347

346348
return taskIds;
@@ -365,11 +367,12 @@ export function validateUiPatchTask(jsonData: any): [string, number[]] {
365367
}
366368

367369
if (isNullish(taskIds)) {
368-
throw new JsonHTTPResponseWithMessage("'task_ids' must be provided");
370+
throw new JsonHTTPResponseWithMessage("'task_ids' must be provided. Task IDs are unique identifiers for scraping tasks.");
369371
}
370372

371373
if (!isListOfValidIds(taskIds)) {
372-
throw new JsonHTTPResponseWithMessage("'task_ids' must be a list of integers");
374+
const taskIdsStr = isObject(taskIds) || Array.isArray(taskIds) ? JSON.stringify(taskIds) : taskIds;
375+
throw new JsonHTTPResponseWithMessage(`'task_ids' with value '${taskIdsStr}' must be a list of integers representing scraping tasks.`);
373376
}
374377

375378
return [action, taskIds];

0 commit comments

Comments
 (0)