Skip to content

fix(core): escape dots in object keys when flattening to prevent path collision - #4374

Closed
okxint wants to merge 1 commit into
triggerdotdev:mainfrom
okxint:fix/flatten-escape-dots-in-keys
Closed

fix(core): escape dots in object keys when flattening to prevent path collision#4374
okxint wants to merge 1 commit into
triggerdotdev:mainfrom
okxint:fix/flatten-escape-dots-in-keys

Conversation

@okxint

@okxint okxint commented Jul 25, 2026

Copy link
Copy Markdown

Problem

Object keys that contain literal dots are misinterpreted as path separators when logs are stored and then displayed. For example:

logger.log("dimensions", { "Key 0.002mm": 31.4 })

Shows up in the dashboard as:

{ "Key 0": { "002mm": 31.4 } }

because the flatten step produces "Key 0.002mm": 31.4 and the unflatten step naively splits on every ..

Fixes #1510

Changes

packages/core/src/v3/utils/flattenAttributes.ts

  • When building the flattened path key for plain object entries (line 208), escape dots in non-array keys: key.replace(/\./g, "\\."). Array indices use bracket notation and don't need escaping.
  • Same escaping applied to Map string keys (line 123).
  • Add splitOnUnescapedDots() helper that tokenizes a flattened key on unescaped dots and unescapes \. back to . in each segment.
  • Switch unflattenAttributes to use splitOnUnescapedDots(key) instead of key.split(".").

packages/core/test/flattenAttributes.test.ts

  • Add a regression test: { "Key 0.002mm": 31.4 } round-trips correctly through flatten → unflatten.
  • Add a nested-key variant: { outer: { "a.b": { inner: 1 } } }.

How did you test this code?

Added two test cases in the existing flattenAttributes.test.ts that reproduce the exact scenario from the issue.

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b9f3ea2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hi @okxint, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 024b4663-9caf-4c73-a8e0-f34ff14aa0cc

📥 Commits

Reviewing files that changed from the base of the PR and between be45cf9 and b9f3ea2.

📒 Files selected for processing (2)
  • packages/core/src/v3/utils/flattenAttributes.ts
  • packages/core/test/flattenAttributes.test.ts

Walkthrough

Updated attribute flattening to escape dots in string keys from Maps and objects. Added parsing that splits only on unescaped dots and restores literal dots during unflattening. Added tests covering simple and nested dotted object keys.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TRI-4123] Logging objects with keys with periods in doesn't render properly in the UI

1 participant