fix(catalog): guard empty subgroup insert after nav-crumb filter (500)
When fetchSubGroupsByPath returns only nav-crumb stubs (e.g. a "Portal"-only page for a Hyundai BODY node), the post-filter set is empty and drizzle .values([]) threw → HTTP 500. Compute `unique` unconditionally and only insert when non-empty; otherwise fall through to the leaf/parts path for a clean empty node. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -785,15 +785,19 @@ export class CatalogService {
|
||||
gearbox,
|
||||
);
|
||||
|
||||
if (subGroups.length > 0) {
|
||||
const seenNames = new Set<string>();
|
||||
const unique = subGroups.filter((sg) => {
|
||||
if (this.isNavCrumbLink(sg.linkPath)) return false;
|
||||
if (seenNames.has(sg.name)) return false;
|
||||
seenNames.add(sg.name);
|
||||
return true;
|
||||
});
|
||||
// After dropping nav-crumb junk the subgroup set can be empty (upstream
|
||||
// returned only a "Portal"/external stub for this node). Guard the insert —
|
||||
// drizzle .values([]) throws — and fall through to the leaf/parts path,
|
||||
// which yields a clean empty node instead of a 500.
|
||||
const seenNames = new Set<string>();
|
||||
const unique = subGroups.filter((sg) => {
|
||||
if (this.isNavCrumbLink(sg.linkPath)) return false;
|
||||
if (seenNames.has(sg.name)) return false;
|
||||
seenNames.add(sg.name);
|
||||
return true;
|
||||
});
|
||||
|
||||
if (unique.length > 0) {
|
||||
const insertData = unique.map((sg) => ({
|
||||
catalogVehicleId,
|
||||
vehicleId: null as string | null,
|
||||
|
||||
Reference in New Issue
Block a user