diff --git a/apps/api/src/integrations/pl24/pl24.service.ts b/apps/api/src/integrations/pl24/pl24.service.ts index 8fd940c..49172df 100644 --- a/apps/api/src/integrations/pl24/pl24.service.ts +++ b/apps/api/src/integrations/pl24/pl24.service.ts @@ -2058,6 +2058,37 @@ export class PL24Service { } } + // Fallback: the primary modelPath returned nothing (e.g. p5fiat is not mapped + // in BACKEND_MODEL_PATH yet). Try the other known P5 listing endpoints so an + // unmapped backend self-discovers its model list instead of silently seeding 0. + // Only runs when the primary yields nothing → no impact on mapped backends. + const candidatePaths = [ + "/extern/vehicle/modelfamilies", + "/extern/vehicle/models", + "/extern/vehicle/modelFamilies", + "/extern/vehicle/catalogs", + "/extern/vehicle/scope", + "/extern/vehicles/vehiclesOverview", + "/extern/model/categories", + ].filter((p) => p !== modelPath); + for (const candidate of candidatePaths) { + try { + const cu = `${this.baseUrl}${catalogBase}${candidate}?lang=${this.language}&serviceName=${serviceName}`; + const cr = await fetch(cu, { method: "GET", headers, signal: AbortSignal.timeout(15000) }); + if (!cr.ok) continue; + const cd = (await cr.json()) as Record; + const cv = this.parseVehicleListResponse(cd, serviceName); + if (cv.length > 0) { + this.logger.log( + `fetchVehicleList: ${serviceName} discovered via ${candidate} (${cv.length} models) — pin BACKEND_MODEL_PATH["${backendKey}"]="${candidate}"`, + ); + return cv; + } + } catch { + // try next candidate + } + } + this.logger.log(`No vehicle list available for ${serviceName} (HTTP ${response.status})`); return []; } catch (err) {