8000 Fix Task Queue Emulator error handling to display error message properly by blidd-google · Pull Request #7916 · firebase/firebase-tools · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix Task Queue Emulator error handling to display error message properly. (#7916)
8 changes: 6 additions & 2 deletions src/emulator/tasksEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
oidcToken?: {
serviceAccountEmail: string;
};
body: any;

Check warning on line 27 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
headers: { [key: string]: string };
};
}
Expand Down Expand Up @@ -163,8 +163,8 @@
return this.running;
}

getStatistics() {

Check warning on line 166 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const stats: Record<string, any> = {};

Check warning on line 167 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
for (const [key, queue] of Object.entries(this.queues)) {
stats[key] = queue.getStatistics();
}
Expand Down Expand Up @@ -203,7 +203,11 @@
const locationId = req.params.location_id;
const queueName = req.params.queue_name;
if (!this.validateQueueId(queueName)) {
res.status(400).send("Invalid Queue ID");
res.status(400).json({
error:
"Queue ID must start with a letter followed by up to 62 letters, numbers, " +
"hyphens, or underscores and must end with a letter or a number",
});
return;
}

Expand Down Expand Up @@ -233,7 +237,7 @@
defaultUri: body.defaultUri,
};
if (taskQueueConfig.rateLimits.maxConcurrentDispatches > 5000) {
res.status(400).send("cannot set maxConcurrentDispatches to a value over 5000");
res.status(400).json({ error: "cannot set maxConcurrentDispatches to a value over 5000" });
return;
}

Expand Down Expand Up @@ -261,10 +265,10 @@
return;
}

req.body.task.name =

Check warning on line 268 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 268 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .task on an `any` value
req.body.task.name ??

Check warning on line 269 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .task on an `any` value
`/projects/${projectId}/locations/${locationId}/queues/${queueName}/tasks/${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`;
req.body.task.httpRequest.body = JSON.parse(atob(req.body.task.httpRequest.body));

Check warning on line 271 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 271 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .task on an `any` value

Check warning on line 271 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`

Check warning on line 271 in src/emulator/tasksEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .task on an `any` value

const task = req.body.task as Task;

Expand Down
Loading
0