n8n-io/n8n · error · Error

Secret capturing failed with error: ${sensitivity.error}

Error message

Secret capturing failed with error: ${sensitivity.error}

What it means

Thrown by browser_capture_secret when analyzeHtmlSensitivity returns { ok: false } — the HTML probe could not produce a clean sensitivity analysis. The error message embeds sensitivity.error, which describes why the analysis failed (e.g. the probe itself errored, the HTML was malformed, or a matcher threw).

Source

Thrown at packages/@n8n/mcp-browser/src/tools/credential.ts:81

		async (state, args, pageId, context) => {
			requireSecretsBuffer(context);
			let value = '';
			if ('redactedKey' in args.element) {
				const { redactedKey } = args.element;
				const sensitivity = analyzeHtmlSensitivity(await state.adapter.probePageHtml(pageId));
				if (sensitivity.ok) {
					const formatMarker = createRedactionMarkerFormatter(sensitivity.hits);
					const markerMap = sensitivity.hits.reduce((result, hit) => {
						result.set(formatMarker(hit), hit.value);
						return result;
					}, new Map<string, string>());

					if (!markerMap.get(redactedKey)) {
						throw new Error(`The marker "${redactedKey}" was not found.`);
					}
					value = markerMap.get(redactedKey)!;
				} else {
					throw new Error(`Secret capturing failed with error: ${sensitivity.error}`);
				}
			} else {
				value = await state.adapter.getElementValue(pageId, { ref: args.element.ref });
			}
			context.secretsBuffer.capture(args.credentialsKey, args.field, value);
			return formatCallToolResult({ ok: true, fieldsCaptured: [args.field] });
		},
		undefined,
		{ skipEnrichment: true },
	);
}

// ---------------------------------------------------------------------------
// browser_create_credential
// ---------------------------------------------------------------------------

export const browserCreateCredentialSchema = z
	.object({

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Wait for the page to fully load (waitForLoadState) before capturing the secret.
  2. Re-probe the page HTML and inspect sensitivity.error for the root cause.
  3. If the field is in an interactive element, use the { ref } form of capture instead of { redactedKey } to bypass the sensitivity-analysis path.

Example fix

// before — capture on half-loaded page
await captureSecret({ redactedKey: '[REDACTED:token:1]', ... }); // sensitivity.error

// after — wait for load, fall back to ref
await page.waitForLoadState('networkidle');
// or use the interactive ref path:
await captureSecret({ element: { ref: 'e5' }, ... });
Defensive patterns

Strategy: validation

Validate before calling

await page.waitForLoadState('domcontentloaded');
const sensitivity = analyzeHtmlSensitivity(await adapter.probePageHtml(pageId));
if (!sensitivity.ok) { /* fall back to ref-based capture or retry after load */ }

Type guard

function sensitivityOk(s: { ok: boolean; error?: string }): boolean {
  return s.ok === true;
}

Try / catch

try {
  await captureSecret({ redactedKey, ... });
} catch (e) {
  if (/Secret capturing failed/.test(e.message)) {
    await page.waitForLoadState('networkidle');
    await captureSecret({ redactedKey, ... });
  } else throw e;
}

Prevention

When it happens

Trigger: Calling browser_capture_secret with a redactedKey when the underlying probePageHtml returned content that analyzeHtmlSensitivity could not process. Triggers when the page HTML is empty, the probe timed out, or a DOM matcher crashed.

Common situations: Page not fully loaded when the secret capture runs (probe returns partial/empty HTML). Cross-origin frame content blocking the probe. Page with extremely large DOM causing the analyzer to fail. Bug in a sensitivity matcher on an unusual element shape.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/a1dc035d36f40366. Report an issue: GitHub.