Skip to content

fix: Handle dots in custom field names for segments, workflows, and templates#347

Open
chamby wants to merge 1 commit intouseplunk:nextfrom
chamby:fix/dotted-custom-field-names
Open

fix: Handle dots in custom field names for segments, workflows, and templates#347
chamby wants to merge 1 commit intouseplunk:nextfrom
chamby:fix/dotted-custom-field-names

Conversation

@chamby
Copy link
Copy Markdown

@chamby chamby commented Apr 9, 2026

Summary

  • Custom fields with dots in their names (e.g., prefix.key) were silently broken across segment filtering, workflow conditions, and email template rendering because the code split on . to build path lookups, treating them as nested JSON paths instead of literal flat keys
  • Fixes SegmentService, WorkflowExecutionService, and template.ts to preserve dots in custom field names
  • Backwards-compatible: fields without dots continue to work identically

Fixes #346

Changes

SegmentService.buildJsonFieldCondition — Use [jsonPath] (single-element array) instead of jsonPath.split('.'). Contact data is always a flat JSON object, so the Prisma JSON path should always be a single key.

WorkflowExecutionService.resolveField — Split only on the first . to separate the top-level field name (data) from the custom field name (prefix.key), instead of splitting on every ..

template.ts getValue — Replace split('.').reduce() with a recursive function that tries direct key lookup at each level before descending via dot-splitting. For data.prefix.key, it enters data, then finds prefix.key as a literal key.

Test plan

  • Verify dynamic segments match contacts with dotted custom field names (e.g., data.app.plan)
  • Verify workflow CONDITION steps correctly evaluate dotted custom fields
  • Verify email templates render {{data.prefix.key}} correctly
  • Verify existing non-dotted fields (data.plan, data.firstName) continue to work

🤖 Generated with Claude Code

…emplates

Custom fields with dots in their names (e.g., "prefix.key") were broken
because the code split on "." to build path lookups, interpreting them as
nested paths instead of literal flat JSON keys.

- SegmentService: Use [jsonPath] instead of jsonPath.split('.') since
  contact data is always a flat JSON object
- WorkflowExecutionService: Split only on the first dot to separate the
  top-level field from the custom field name
- template.ts: Use recursive first-dot splitting with direct key lookup
  before descending into nested objects

Fixes useplunk#346

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Custom fields with dots in names break segment filtering, workflow conditions, and template rendering

1 participant