{"record":{"id":"a1dc035d36f40366","repo":"n8n-io/n8n","slug":"secret-capturing-failed-with-error-sensitivity","errorCode":null,"errorMessage":"Secret capturing failed with error: ${sensitivity.error}","messagePattern":"Secret capturing failed with error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/mcp-browser/src/tools/credential.ts","lineNumber":81,"sourceCode":"\t\tasync (state, args, pageId, context) => {\n\t\t\trequireSecretsBuffer(context);\n\t\t\tlet value = '';\n\t\t\tif ('redactedKey' in args.element) {\n\t\t\t\tconst { redactedKey } = args.element;\n\t\t\t\tconst sensitivity = analyzeHtmlSensitivity(await state.adapter.probePageHtml(pageId));\n\t\t\t\tif (sensitivity.ok) {\n\t\t\t\t\tconst formatMarker = createRedactionMarkerFormatter(sensitivity.hits);\n\t\t\t\t\tconst markerMap = sensitivity.hits.reduce((result, hit) => {\n\t\t\t\t\t\tresult.set(formatMarker(hit), hit.value);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}, new Map<string, string>());\n\n\t\t\t\t\tif (!markerMap.get(redactedKey)) {\n\t\t\t\t\t\tthrow new Error(`The marker \"${redactedKey}\" was not found.`);\n\t\t\t\t\t}\n\t\t\t\t\tvalue = markerMap.get(redactedKey)!;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Secret capturing failed with error: ${sensitivity.error}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvalue = await state.adapter.getElementValue(pageId, { ref: args.element.ref });\n\t\t\t}\n\t\t\tcontext.secretsBuffer.capture(args.credentialsKey, args.field, value);\n\t\t\treturn formatCallToolResult({ ok: true, fieldsCaptured: [args.field] });\n\t\t},\n\t\tundefined,\n\t\t{ skipEnrichment: true },\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// browser_create_credential\n// ---------------------------------------------------------------------------\n\nexport const browserCreateCredentialSchema = z\n\t.object({","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/mcp-browser/src/tools/credential.ts#L63-L99","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wait for the page to fully load (waitForLoadState) before capturing the secret.","Re-probe the page HTML and inspect sensitivity.error for the root cause.","If the field is in an interactive element, use the { ref } form of capture instead of { redactedKey } to bypass the sensitivity-analysis path."],"exampleFix":"// before — capture on half-loaded page\nawait captureSecret({ redactedKey: '[REDACTED:token:1]', ... }); // sensitivity.error\n\n// after — wait for load, fall back to ref\nawait page.waitForLoadState('networkidle');\n// or use the interactive ref path:\nawait captureSecret({ element: { ref: 'e5' }, ... });","handlingStrategy":"validation","validationCode":"await page.waitForLoadState('domcontentloaded');\nconst sensitivity = analyzeHtmlSensitivity(await adapter.probePageHtml(pageId));\nif (!sensitivity.ok) { /* fall back to ref-based capture or retry after load */ }","typeGuard":"function sensitivityOk(s: { ok: boolean; error?: string }): boolean {\n  return s.ok === true;\n}","tryCatchPattern":"try {\n  await captureSecret({ redactedKey, ... });\n} catch (e) {\n  if (/Secret capturing failed/.test(e.message)) {\n    await page.waitForLoadState('networkidle');\n    await captureSecret({ redactedKey, ... });\n  } else throw e;\n}","preventionTips":["Wait for the page to settle before capturing non-interactive secrets.","Prefer the { ref } capture path for interactive elements to bypass the probe.","Inspect sensitivity.error to diagnose probe failures."],"tags":["credential","sensitivity","html-probe","load-state"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}