Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Skip AST construction only for link-free settings sections
pulse-triage[bot]75adb05aa8d7
diff --git a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.ts b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.tsindex a2c7485d7a..c6e97791a3 100644--- a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.ts+++ b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.ts@@ -1,4 +1,13 @@-import { describe, expect, it } from 'vitest';+import { describe, expect, it, vi } from 'vitest';+import ts from 'typescript';+import runtimeControlsSource from '@/components/Settings/AIRuntimeControlsSection.tsx?raw';++vi.mock('typescript', async (importOriginal) => {+ const actual = await importOriginal<typeof import('typescript')>();+ return {+ default: { ...actual.default, createSourceFile: vi.fn(actual.default.createSourceFile) },+ };+});import { settingsDocumentationLinkViolations } from './settingsDocumentationLinkContract';const valid = `@@ -8,6 +17,23 @@ const valid = ``;describe('surviving settings documentation link contract', () => {+ it('does not parse a link-free surviving runtime section', () => {+ vi.mocked(ts.createSourceFile).mockClear();+ expect(settingsDocumentationLinkViolations(runtimeControlsSource)).toEqual([]);+ expect(ts.createSourceFile).not.toHaveBeenCalled();+ });++ it.each([+ 'export const Link = () => <a href="/docs">Docs</a>;',+ 'export const Link = () => <\n a href="/docs">Docs</a>;',+ valid.replace('ExternalTextLink', 'External\\u0054extLink'),+ 'import { TERMS_DOC_URL as terms } from "@/utils/docsLinks"; export const Section = () => <p>No link</p>;',+ ])('still parses possible anchors, aliases and escaped bindings: %s', (source) => {+ vi.mocked(ts.createSourceFile).mockClear();+ expect(settingsDocumentationLinkViolations(source)).not.toEqual([]);+ expect(ts.createSourceFile).toHaveBeenCalledOnce();+ });+it('accepts an actual shared link to shipped Terms', () => {expect(settingsDocumentationLinkViolations(valid)).toEqual([]);});diff --git a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.ts b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.tsindex 4ce5f20278..a6c9cb90a4 100644--- a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.ts+++ b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.ts@@ -3,6 +3,18 @@ import ts from 'typescript';// Inspect surviving JSX, not symbol mentions: removing a whole link is valid,// but leaving an import or comment must not conceal a raw or misdirected link.export function settingsDocumentationLinkViolations(source: string): string[] {+ // Removed controls can leave a section with no documentation link at all.+ // Avoid constructing an AST in that common case. Any possible raw anchor,+ // shared/Terms binding or escape still takes the full structural check.+ if (+ !source.includes('ExternalTextLink') &&+ !source.includes('TERMS_DOC_URL') &&+ !/<\s*a\b/.test(source) &&+ !source.includes('\\')+ ) {+ return [];+ }+const file = ts.createSourceFile('settings.tsx',source,