From f3157d18c2ba5c597d56e11e2f35311bd600b0e0 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Mon, 2 Mar 2026 10:40:41 +0100 Subject: [PATCH 1/2] Add reproduction for sentry-javascript#19572 Co-Authored-By: Claude Opus 4.6 --- sentry-javascript/19572/README.md | 53 ++++++++++++++++ sentry-javascript/19572/index.js | 90 ++++++++++++++++++++++++++++ sentry-javascript/19572/package.json | 12 ++++ 3 files changed, 155 insertions(+) create mode 100644 sentry-javascript/19572/README.md create mode 100644 sentry-javascript/19572/index.js create mode 100644 sentry-javascript/19572/package.json diff --git a/sentry-javascript/19572/README.md b/sentry-javascript/19572/README.md new file mode 100644 index 0000000..0fc02b7 --- /dev/null +++ b/sentry-javascript/19572/README.md @@ -0,0 +1,53 @@ +# Reproduction for sentry-javascript#19572 + +**Issue:** https://github.com/getsentry/sentry-javascript/issues/19572 + +## Description + +`localVariablesIntegration` does not capture nested object contents in AWS Lambda. Local variables that are objects appear as empty `{}` in Sentry, even though the same object attached via `Sentry.setExtra()` is fully preserved. Increasing `normalizeDepth` does not help. + +## Steps to Reproduce + +1. Export your Sentry DSN (or use the dummy one for local testing): + ```bash + export SENTRY_DSN= + ``` + +2. Install dependencies: + ```bash + npm install + ``` + +3. Run the reproduction: + ```bash + npm start + ``` + +## Expected Behavior + +The `payload` local variable should appear with its full nested structure in the Local Variables section, similar to how it appears when attached via `Sentry.setExtra()`. + +## Actual Behavior + +The `payload` local variable is captured as just `{}` (empty object) with no nested properties, while the exact same object attached via `Sentry.setExtra()` shows the complete structure: + +``` +--- Local variables captured for processRequest --- +{ + "payload": {}, + "serialized": {} +} + +--- Same object attached via Sentry.setExtra() --- +{ + "payload_debug": { + "user": { "id": 123, "profile": { "name": "Test User", ... } }, + "items": [{ "id": 1, "nested": { "deep": { "value": "should be visible" } } }] + } +} +``` + +## Environment + +- @sentry/aws-serverless: 10.36.0 +- Node.js: v22+ diff --git a/sentry-javascript/19572/index.js b/sentry-javascript/19572/index.js new file mode 100644 index 0000000..4d04ace --- /dev/null +++ b/sentry-javascript/19572/index.js @@ -0,0 +1,90 @@ +const Sentry = require("@sentry/aws-serverless"); + +Sentry.init({ + dsn: process.env.SENTRY_DSN || "https://examplePublicKey@o0.ingest.sentry.io/0", + integrations: [ + Sentry.localVariablesIntegration({ includeOutOfAppFrames: true }), + Sentry.extraErrorDataIntegration(), + ], + includeLocalVariables: true, + // Try increasing normalizeDepth - the issue reports this doesn't help + normalizeDepth: 10, + beforeSend(event) { + // Inspect the local variables captured in stack frames + const frames = event.exception?.values?.[0]?.stacktrace?.frames || []; + for (const frame of frames) { + if (frame.vars && frame.function === "processRequest") { + console.log("\n--- Local variables captured for processRequest ---"); + console.log(JSON.stringify(frame.vars, null, 2)); + } + } + + // Also inspect extra data for comparison + if (event.extra?.payload_debug) { + console.log("\n--- Same object attached via Sentry.setExtra() ---"); + console.log(JSON.stringify(event.extra.payload_debug, null, 2)); + } + + return event; + }, +}); + +// Simulate a Lambda-like handler that processes a deeply nested payload +async function processRequest() { + // This is the deeply nested object that should appear in local variables + const payload = { + user: { + id: 123, + profile: { + name: "Test User", + address: { + street: "123 Main St", + city: "Springfield", + state: "IL", + geo: { + lat: 39.7817, + lng: -89.6501, + metadata: { + source: "geocoder", + confidence: 0.95, + details: { + provider: "mapbox", + timestamp: "2024-01-01T00:00:00Z", + }, + }, + }, + }, + }, + }, + items: [ + { + id: 1, + nested: { + deep: { + value: "should be visible", + }, + }, + }, + ], + }; + + // Attach via extra for comparison - this DOES show the full object in Sentry + Sentry.setExtra("payload_debug", payload); + + // BUG: When this error is captured, the `payload` local variable + // appears as just {} in Sentry's Local Variables panel, + // while the same object attached via setExtra() preserves all nesting. + throw new Error("Test error - check local variables for payload"); +} + +// Wait for LocalVariables worker thread to initialize before triggering the error +setTimeout(async () => { + try { + await processRequest(); + } catch (error) { + Sentry.captureException(error); + await Sentry.flush(5000); + console.log("\n--- Done ---"); + console.log("BUG: payload appears as {} in local variables but is fully preserved in extra data."); + } +}, 2000); diff --git a/sentry-javascript/19572/package.json b/sentry-javascript/19572/package.json new file mode 100644 index 0000000..3c9edf6 --- /dev/null +++ b/sentry-javascript/19572/package.json @@ -0,0 +1,12 @@ +{ + "name": "repro-sentry-javascript-19572", + "version": "1.0.0", + "private": true, + "description": "Reproduction for sentry-javascript#19572 - LocalVariables truncates nested objects", + "scripts": { + "start": "node index.js" + }, + "dependencies": { + "@sentry/aws-serverless": "10.36.0" + } +} From 593d98cf6e71194dc094420e105be641c39fa9e3 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Mon, 2 Mar 2026 10:47:58 +0100 Subject: [PATCH 2/2] Add simple local variable controls to confirm bug is specific to nested objects Co-Authored-By: Claude Opus 4.6 --- sentry-javascript/19572/README.md | 14 ++++++++------ sentry-javascript/19572/index.js | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sentry-javascript/19572/README.md b/sentry-javascript/19572/README.md index 0fc02b7..d65c359 100644 --- a/sentry-javascript/19572/README.md +++ b/sentry-javascript/19572/README.md @@ -34,19 +34,21 @@ The `payload` local variable is captured as just `{}` (empty object) with no nes ``` --- Local variables captured for processRequest --- { - "payload": {}, - "serialized": {} + "simpleString": "hello world", // ✅ primitive string captured + "simpleNumber": 42, // ✅ primitive number captured + "flatObject": { "key": "value", "count": 10 }, // ✅ flat object captured + "payload": {} // ❌ nested object is empty! } --- Same object attached via Sentry.setExtra() --- { - "payload_debug": { - "user": { "id": 123, "profile": { "name": "Test User", ... } }, - "items": [{ "id": 1, "nested": { "deep": { "value": "should be visible" } } }] - } + "user": { "id": 123, "profile": { "name": "Test User", ... } }, + "items": [{ "id": 1, "nested": { "deep": { "value": "should be visible" } } }] } ``` +Primitives and flat objects are captured correctly. Only deeply nested objects lose their contents. + ## Environment - @sentry/aws-serverless: 10.36.0 diff --git a/sentry-javascript/19572/index.js b/sentry-javascript/19572/index.js index 4d04ace..1c8769c 100644 --- a/sentry-javascript/19572/index.js +++ b/sentry-javascript/19572/index.js @@ -31,6 +31,11 @@ Sentry.init({ // Simulate a Lambda-like handler that processes a deeply nested payload async function processRequest() { + // Simple (non-nested) local variables for comparison + const simpleString = "hello world"; + const simpleNumber = 42; + const flatObject = { key: "value", count: 10 }; + // This is the deeply nested object that should appear in local variables const payload = { user: {