This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-horizon-ui.git
The following commit(s) were added to refs/heads/main by this push:
new 6d1b338 bff: fix bundled-mode template lookup in alerts +
global-defaults loaders
6d1b338 is described below
commit 6d1b3387bc2aa38d89169a705dd135627343ef84
Author: Wu Sheng <[email protected]>
AuthorDate: Wed May 20 08:53:48 2026 +0800
bff: fix bundled-mode template lookup in alerts + global-defaults loaders
After `pnpm package`, esbuild rolls every BFF module into a single
dist/server.js sitting next to dist/bundled_templates/. In the container
that's /app/server.js + /app/bundled_templates/. The two affected
loaders carried `__dirname`-relative candidates designed for the SOURCE
tree (apps/bff/src/logic/<area>/loader.ts walking up to apps/bff/src/
bundled_templates/) but no candidate that matches the bundled layout.
The bug surfaces as three identical paths in the error message because
`/app` + `../*` + `../../*` + `../../../*` all collapse above WORKDIR,
and `node:path.resolve` clamps at `/` — so each candidate prints as
`/bundled_templates/...` (the prefix that DOES exist in the source tree
but doesn't exist in the container's root filesystem).
Fix: prepend `<HERE>/bundled_templates/...` as the first candidate in
both `alarms/bundled.ts` and `templates/global-defaults-bundled.ts` — the
same shape the layer + overview loaders already use. Also collapse the
two redundant source-tree probes into the single one that's actually
correct for the source layout (`../../bundled_templates/...`), and add
`<cwd>/bundled_templates/...` as a final escape hatch for operators
running from a relocated dist/.
Verified: HERE for both files in dev is apps/bff/src/logic/<area>/;
two `..` reach apps/bff/src/bundled_templates/. HERE in the bundle is
the dir holding server.js; zero `..` reach the sibling
bundled_templates/.
---
apps/bff/src/logic/alarms/bundled.ts | 18 ++++++++++++++++--
.../bff/src/logic/templates/global-defaults-bundled.ts | 13 +++++++++++--
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/apps/bff/src/logic/alarms/bundled.ts
b/apps/bff/src/logic/alarms/bundled.ts
index b237197..131923f 100644
--- a/apps/bff/src/logic/alarms/bundled.ts
+++ b/apps/bff/src/logic/alarms/bundled.ts
@@ -49,10 +49,24 @@ export function invalidateAlertBundleCache(): void {
}
function locateAlertBundle(): string {
+ // Probe order:
+ // 1. <HERE>/bundled_templates/... — bundled BFF (esbuild). After
+ // `pnpm package`, dist/server.js sits next to dist/bundled_templates/,
+ // so HERE = .../dist and the file is one level deeper. In the
+ // container that's /app/server.js → /app/bundled_templates/. The
+ // sibling layer + overview loaders already include this entry
+ // first; the alert loader was missing it, which made every probe
+ // collapse above WORKDIR (node:path.resolve clamps at /) and
+ // print the same path three times.
+ // 2. <HERE>/../../bundled_templates/... — dev (tsx). Source is at
+ // apps/bff/src/logic/alarms/, bundled_templates is two levels up
+ // at apps/bff/src/bundled_templates/.
+ // 3. <cwd>/bundled_templates/... — operator running from a
+ // relocated dist/ where neither path above works.
const candidates = [
+ resolve(HERE, 'bundled_templates/alert/page-setup.json'),
resolve(HERE, '../../bundled_templates/alert/page-setup.json'),
- resolve(HERE, '../bundled_templates/alert/page-setup.json'),
- resolve(HERE, '../../../bundled_templates/alert/page-setup.json'),
+ resolve(process.cwd(), 'bundled_templates/alert/page-setup.json'),
];
for (const c of candidates) {
if (existsSync(c)) return c;
diff --git a/apps/bff/src/logic/templates/global-defaults-bundled.ts
b/apps/bff/src/logic/templates/global-defaults-bundled.ts
index f639728..384747d 100644
--- a/apps/bff/src/logic/templates/global-defaults-bundled.ts
+++ b/apps/bff/src/logic/templates/global-defaults-bundled.ts
@@ -68,10 +68,19 @@ export function invalidateGlobalDefaultsBundledCache():
void {
}
function locate(rel: string): string {
+ // Same probe order as the alert + layer + overview loaders:
+ // 1. <HERE>/bundled_templates/... — bundled BFF (esbuild rolls
+ // this loader into dist/server.js; HERE = .../dist and the
+ // bundled_templates folder sits as a sibling). In the container
+ // this resolves to /app/bundled_templates/.
+ // 2. <HERE>/../../bundled_templates/... — dev (tsx). Source is at
+ // apps/bff/src/logic/templates/, bundled_templates is two levels
+ // up at apps/bff/src/bundled_templates/.
+ // 3. <cwd>/bundled_templates/... — operator-relocated dist/.
const candidates = [
+ resolve(HERE, `bundled_templates/${rel}`),
resolve(HERE, `../../bundled_templates/${rel}`),
- resolve(HERE, `../bundled_templates/${rel}`),
- resolve(HERE, `../../../bundled_templates/${rel}`),
+ resolve(process.cwd(), `bundled_templates/${rel}`),
];
for (const c of candidates) {
if (existsSync(c)) return c;