fix(pl24): demo-page retry in fetchP4Page + Volvo drill diagnostics
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
PL24 serves a stripped NOT_LOGGED_IN_DEMO page (no groups/parts) when the service token is stale. decodeVinForService retries on this, but drill paths (fetchSubGroupsByPath/fetchPartsByPath) reach upstream only via fetchP4Page, which didn't — so Volvo subgroup drilling parsed empty demo pages. Retry once with fresh auth on a demo page. Adds a Volvo-drill diagnostic log. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -161,6 +161,9 @@ export class PL24FordLegacyService {
|
|||||||
const lp = href.startsWith("/") ? href : `${basePath}/${href}`;
|
const lp = href.startsWith("/") ? href : `${basePath}/${href}`;
|
||||||
subs.push({ id: href, code: href, name, linkPath: lp });
|
subs.push({ id: href, code: href, name, linkPath: lp });
|
||||||
}
|
}
|
||||||
|
this.logger.log(
|
||||||
|
`Volvo vin-group drill: htmlLen=${html.length} groupParamLinks=${(html.match(/group\d+=/g) || []).length} subs=${subs.length}${html.includes("NOT_LOGGED_IN_DEMO") ? " [DEMO]" : ""}`,
|
||||||
|
);
|
||||||
if (subs.length > 0) {
|
if (subs.length > 0) {
|
||||||
await this.redis.setJson(cacheKey, subs, 86400);
|
await this.redis.setJson(cacheKey, subs, 86400);
|
||||||
}
|
}
|
||||||
@@ -3156,6 +3159,7 @@ export class PL24FordLegacyService {
|
|||||||
serviceName: string,
|
serviceName: string,
|
||||||
isFullUrl = false,
|
isFullUrl = false,
|
||||||
account: "tr" | "de" = "tr",
|
account: "tr" | "de" = "tr",
|
||||||
|
retried = false,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
// Some catalogs (Volvo vin-group.action) store hrefs relative to the catalog
|
// Some catalogs (Volvo vin-group.action) store hrefs relative to the catalog
|
||||||
// directory (e.g. "vin-group.action?group1=…"). Prefix the service basePath
|
// directory (e.g. "vin-group.action?group1=…"). Prefix the service basePath
|
||||||
@@ -3206,7 +3210,21 @@ export class PL24FordLegacyService {
|
|||||||
return JSON.stringify(json);
|
return JSON.stringify(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.text();
|
const html = await response.text();
|
||||||
|
// Demo mode: PL24 serves a stripped NOT_LOGGED_IN_DEMO page (no real
|
||||||
|
// groups/parts) when the service token is stale. decodeVinForService
|
||||||
|
// retries on this, but drill paths reach upstream only through here —
|
||||||
|
// so retry once with fresh auth before parsing an empty page.
|
||||||
|
if (!retried && html.includes("PL24_SUPPORT")) {
|
||||||
|
const support = this.extractScriptVariable<FordPL24Support>(html, "PL24_SUPPORT");
|
||||||
|
if (support?.demo || support?.role === "NOT_LOGGED_IN_DEMO") {
|
||||||
|
this.logger.warn(`Ford legacy: demo page for ${serviceName}, re-authing + retry`);
|
||||||
|
this.authService.clearTokensForAccount(account);
|
||||||
|
await this.authService.authorizeServiceForAccount(serviceName, account);
|
||||||
|
return this.fetchP4Page(url, serviceName, isFullUrl, account, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return html;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error as Error;
|
const err = error as Error;
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user