diff --git a/src/expert-claim/expert-claim.service.ts b/src/expert-claim/expert-claim.service.ts index c6f6d0a..21e3972 100644 --- a/src/expert-claim/expert-claim.service.ts +++ b/src/expert-claim/expert-claim.service.ts @@ -4655,7 +4655,7 @@ export class ExpertClaimService { previousNorm, ); - const nextNorm = body.selectedParts.map((p) => + const nextNormRaw = body.selectedParts.map((p) => sanitizeDamageSelectedPartV2( { id: p.id ?? null, @@ -4669,6 +4669,20 @@ export class ExpertClaimService { ), ); + // Drop ghost entries: internal parts with neither a catalog id nor a name + // (these are frontend artifacts from uninitialised form rows). + const nextNorm = nextNormRaw.filter((p) => { + if (p.id != null) return true; + return String(p.name ?? "").trim().length > 0; + }); + + if (nextNorm.length === 0) { + throw new BadRequestException( + "selectedParts must contain at least one identifiable part. " + + "Each entry must have a numeric catalog id or a non-empty name.", + ); + } + const matchPreviousIndex = ( next: (typeof nextNorm)[0], previous: typeof previousNorm,