Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Withdraw TrueNAS access denials even after a draft edit

pulse-triage[bot]0aaaa39684c8
diff --git a/frontend-modern/browser-verification/db4fc1ccffe498b5.json b/frontend-modern/browser-verification/db4fc1ccffe498b5.json
new file mode 100644
index 0000000000..491421be35
--- /dev/null
+++ b/frontend-modern/browser-verification/db4fc1ccffe498b5.json
@@ -0,0 +1,34 @@
+{
+ "version": 1,
+ "base_sha": "f886613300bc5f4785827ae0266fd223e2ac5e40",
+ "verified_at": "2026-11-02T20:30:15.753170Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts": "f551123f5abdfe5d231da5d5dd7d5022bfefa7bf3012d3fb7087628418b5158e"
+ },
+ "routes": [
+ "/settings/infrastructure"
+ ],
+ "viewports": [
+ {
+ "width": 1280,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Actual App/Settings/Infrastructure/TrueNAS saved credential editor. Safe local HTTP fixtures use the real API client, desktop Chromium/light and narrow WebKit/dark; Playwright 1.56.1.",
+ "Held Test and Preview, ordinary Name edit, same-reader HTTP403, credential withdrawal and explicit reload/fresh Test recovery. Auth-free fixture metadata retains infrastructure capabilities; native login/tenant/appliance recovery is not claimed."
+ ],
+ "interactions": [
+ "37 assertions and eight captures opened natively with view_image. Each pending Name edit is accepted. Denial removes key/owner form fields, shows safe reload guidance and does not repeat the request or automatically read inventory. Fresh explicit reload starts with empty key and Test preserves stored key marker, owner, HTTPS, verification and pin.",
+ "Pixels: masked draft before denial; afterwards existing Manage shell remains with its missing-configuration fallback plus safe denial toast, with no credential inputs. Narrow form scrolls vertically and lower actions are exercised, not all visible in captures. No save/removal or changed grants.",
+ "Both browser/context trees and websocket/Vite/HTTP servers close. Earlier login redirect, repeated-load and short admission-timeout observations retained separately, not counted passed or diagnosed. Same-reader HTTP401, stale-draft errors/success and obsolete-reader denials additionally covered by registered source tests."
+ ]
+}
diff --git a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
index eb0a0c0782..ccc5721f1c 100644
--- a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
@@ -292,6 +292,121 @@ describe('TrueNAS reader lifetime', () => {
expect(notificationStore.success).not.toHaveBeenCalled();
});
+ for (const action of ['Test', 'Preview'] as const)
+ for (const status of [401, 403])
+ for (const saved of [true, false])
+ it(`withdraws edited ${saved ? 'saved' : 'new'} draft on ${action} HTTP ${status}, then recovers only by fresh read`, async () => {
+ const method =
+ action === 'Test'
+ ? saved
+ ? 'testSavedConnection'
+ : 'testConnection'
+ : saved
+ ? 'previewSavedConnection'
+ : 'previewConnection';
+ const pending = deferred<never>();
+ vi.mocked(TrueNASAPI[method]).mockReturnValueOnce(pending.promise);
+ const { result } = renderHook(() => useTrueNASSettingsPanelState());
+ await ready(result);
+ const old = result.connections()[0];
+ if (saved) openDraft(result);
+ else {
+ result.openCreateDialog();
+ result.updateForm({
+ host: 'nas.example.invalid',
+ username: 'monitor',
+ apiKey: 'synthetic-draft',
+ });
+ }
+ const task = action === 'Test' ? result.testCurrentForm() : result.previewCurrentForm();
+ expect(TrueNASAPI[method]).toHaveBeenCalledTimes(1);
+ result.updateForm({ name: 'Name edited while request is pending' });
+ expect(result.form().name).toBe('Name edited while request is pending');
+ pending.reject({ status, message: 'private-provider-detail' });
+ await task;
+ expect(result.connections()).toEqual([]);
+ expect(result.dialogOpen()).toBe(false);
+ expect(result.form().apiKey).toBe('');
+ expect(result.form().username).toBe('');
+ expect(result.monitoredSystemPreview()).toBeNull();
+ expect(result.monitoredSystemPreviewError()).toBeNull();
+ expect(result.loadingError()).toContain('access could not be verified');
+ expect(result.testing() || result.previewing()).toBe(false);
+ expect(notificationStore.success).not.toHaveBeenCalled();
+ expect(notificationStore.error).toHaveBeenCalledWith(result.loadingError());
+ expect(notificationStore.error).not.toHaveBeenCalledWith('private-provider-detail');
+ expect(logger.error).not.toHaveBeenCalled();
+ result.openEditDialog(old);
+ result.openCreateDialog();
+ expect(result.dialogOpen()).toBe(false);
+ expect(TrueNASAPI.listConnections).toHaveBeenCalledTimes(1);
+ expect(TrueNASAPI[method]).toHaveBeenCalledTimes(1); // No replay on denial.
+ await result.loadConnections();
+ await ready(result);
+ result.openEditDialog(result.connections()[0]);
+ expect(result.form().apiKey).toBe('');
+ expect(result.loadingError()).toBeNull();
+ vi.mocked(TrueNASAPI.testSavedConnection).mockResolvedValueOnce({
+ success: true,
+ } as never);
+ expect(await result.testCurrentForm()).toBe(true);
+ expect(notificationStore.success).toHaveBeenCalledWith('TrueNAS connection successful');
+ });
+
+ for (const action of ['Test', 'Preview'] as const)
+ for (const status of [401, 403])
+ it(`ignores old-reader ${action} HTTP ${status} after an A-to-B-to-A replacement`, async () => {
+ const method = action === 'Test' ? 'testSavedConnection' : 'previewSavedConnection';
+ const pending = deferred<never>();
+ vi.mocked(TrueNASAPI[method]).mockReturnValueOnce(pending.promise);
+ const [currentUser, setUser] = createSignal('a');
+ const { result } = renderHook(() => useTrueNASSettingsPanelState({ currentUser }));
+ await ready(result);
+ openDraft(result);
+ const task = action === 'Test' ? result.testCurrentForm() : result.previewCurrentForm();
+ const options = vi.mocked(TrueNASAPI[method]).mock.calls[0][2]!;
+ result.updateForm({ name: 'Obsolete edited draft' });
+ setUser('b');
+ setUser('a');
+ await ready(result);
+ openDraft(result);
+ pending.reject({ status, message: 'obsolete-private-detail' });
+ await task;
+ expect(options.signal?.aborted).toBe(true);
+ expect(result.connections()).toHaveLength(1);
+ expect(result.dialogOpen()).toBe(true);
+ expect(result.form().apiKey).toBe('synthetic-draft');
+ expect(result.loadingError()).toBeNull();
+ expect(result.testing() || result.previewing()).toBe(false);
+ expect(notificationStore.error).not.toHaveBeenCalled();
+ expect(notificationStore.success).not.toHaveBeenCalled();
+ expect(logger.error).not.toHaveBeenCalled();
+ expect(TrueNASAPI.listConnections).toHaveBeenCalledTimes(3);
+ });
+
+ for (const action of ['Test', 'Preview'] as const)
+ it(`ignores a stale-draft ${action} ordinary error without withdrawing the current reader`, async () => {
+ const method = action === 'Test' ? 'testSavedConnection' : 'previewSavedConnection';
+ const pending = deferred<never>();
+ vi.mocked(TrueNASAPI[method]).mockReturnValueOnce(pending.promise);
+ const { result } = renderHook(() => useTrueNASSettingsPanelState());
+ await ready(result);
+ openDraft(result);
+ const task = action === 'Test' ? result.testCurrentForm() : result.previewCurrentForm();
+ result.updateForm({ name: 'Keep this current draft' });
+ pending.reject({ status: 500, message: 'obsolete-provider-detail' });
+ await task;
+ expect(result.connections()).toHaveLength(1);
+ expect(result.dialogOpen()).toBe(true);
+ expect(result.form().name).toBe('Keep this current draft');
+ expect(result.form().apiKey).toBe('synthetic-draft');
+ expect(result.loadingError()).toBeNull();
+ expect(result.monitoredSystemPreviewError()).toBeNull();
+ expect(result.testing() || result.previewing()).toBe(false);
+ expect(notificationStore.error).not.toHaveBeenCalled();
+ expect(logger.error).not.toHaveBeenCalled();
+ });
+
it('starts a single mutation and does not retarget it while busy', async () => {
const pending = deferred<never>();
vi.mocked(TrueNASAPI.updateConnection).mockReturnValueOnce(pending.promise);
diff --git a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
index ed6393418c..39847f94fb 100644
--- a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
@@ -440,7 +440,11 @@ export function useTrueNASSettingsPanelState({
notificationStore.success('TrueNAS connection successful');
return true;
} catch (error) {
- if (isCurrent())
+ // Access belongs to the reader, not the tested draft. A Name/credential
+ // edit may obsolete a result, but must not hide this reader's denial.
+ if (!isCurrentReader(accepted)) return false;
+ if (withdrawOnDenial(error)) notificationStore.error(loadingError()!);
+ else if (isCurrent())
handleActionError(
error,
'TrueNAS connection failed',
@@ -499,8 +503,14 @@ export function useTrueNASSettingsPanelState({
setMonitoredSystemPreview(preview);
return preview;
} catch (error) {
+ // An obsolete reader cannot withdraw its replacement; an obsolete draft
+ // on the same reader still must withdraw on lost access.
+ if (!isCurrentReader(accepted)) return null;
+ if (withdrawOnDenial(error)) {
+ notificationStore.error(loadingError()!);
+ return null;
+ }
if (!isCurrent()) return null;
- if (withdrawOnDenial(error)) return null;
const unavailableState = monitoredSystemImpactPreviewUnavailableStateFromError(error);
if (unavailableState) setMonitoredSystemPreviewUnavailableState(unavailableState);
else