mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
fix: add race condition guard and null check in group queries
- createOrFindPackageGroup: catch unique constraint violation from concurrent creates and fall back to findFirst - createManualGroup: guard against empty package results before accessing first element Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -609,6 +609,9 @@ export async function createManualGroup(name: string, packageIds: string[]) {
|
||||
where: { id: { in: packageIds } },
|
||||
select: { sourceChannelId: true },
|
||||
});
|
||||
if (pkgs.length === 0) {
|
||||
throw new Error("No matching packages found");
|
||||
}
|
||||
const channelIds = new Set(pkgs.map((p) => p.sourceChannelId));
|
||||
if (channelIds.size > 1) {
|
||||
throw new Error("Cannot group packages from different channels");
|
||||
|
||||
Reference in New Issue
Block a user