feat(dashboardAPI): resolve Grafana folder by name (fixes stale folderUid 400s)

A pinned folderUid goes stale whenever Grafana is rebuilt — the same-named
folder returns with a fresh uid and every dashboard upsert then 400s
"folder not found", silently dropping all generated dashboards.

Add a folderTitle config field: when set, resolveFolderUid() looks the folder
up by name (GET /api/folders), creates it if absent (POST /api/folders),
caches the uid for the process, and falls back to the configured folderUid on
any failure (never worse than the pinned behavior). The emit handlers
(registerChild/regenerateDashboard/emitDashboardsFor) are now async and await
the resolution. folderUid retained as an explicit override/fallback.

Locked by slice48-folder-resolve-by-name; existing emit tests made async.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-05-27 21:02:38 +02:00
parent 5533293647
commit 5d651b59ef
8 changed files with 217 additions and 27 deletions

View File

@@ -75,6 +75,7 @@ class nodeClass {
host: uiConfig.host || 'localhost',
port: Number(uiConfig.port || 3000),
bearerToken,
folderTitle: uiConfig.folderTitle || '',
folderUid: uiConfig.folderUid || '',
},
defaultBucket: uiConfig.defaultBucket || process.env.INFLUXDB_BUCKET || '',