Skip to content

[Bug]: Structured logger adds unneccessary \n to logging payloads #322

@embano1

Description

@embano1

Title

[Bug]: Structured logger adds unneccessary \n to logging payloads

Expected Behavior

I expected no \n in my log output e.g.,

{"requestId":"544f81ff-41cf-4d81-a3b5-10f391f0b70c","timestamp":"2025-11-25T17:14:03.442Z","level":"INFO","executionArn":"92710866-c089-4373-82ba-2182942d4da1","message":"Order successfully processed: { orderId: 'ORD-123', status: 'processed', timestamp: '2025-2025-2025' }"}

Actual Behavior

Instead, I'm receiving \n formatted output when the timestamp field exceeds a certain length:

{"requestId":"dda382c1-aefa-40e8-a4e3-7dd7b1824768","timestamp":"2025-11-25T17:14:37.218Z","level":"INFO","executionArn":"52152021-8326-41c1-b8bb-cc80e548797b","message":"Order successfully processed: {\n  orderId: 'ORD-123',\n  status: 'processed',\n  timestamp: '2025-2025-2025'\n}"}

For example, when timestamp is just 2025-2025 there's no \n. Not sure where the code sits which adds \n if the object/field exceeds a certain length?

Steps to Reproduce

Here's my code which prints the above during unit testing

const processed = await context.step("process-order", async (stepCtx) => {
        return { orderId: event.orderId, status: "processed", timestamp: "2025-2025-2025" }
    });
    context.logger.info("Order successfully processed:", processed);

SDK Version

development (0df43d6)

Node.js Version

22.x

Is this a regression?

No

Last Working Version

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions