fix: parse identifiers with leading underscores - #369
Draft
joaothallis wants to merge 2 commits into
Draft
Conversation
WhatsApp webhook payloads carry vendor keys such as _vnd, so journey expressions like @event.message._vnd.v1.chat must resolve. The atom grammar rejected underscores in the first position, truncating the expression at the first underscore-leading attribute and leaving the rest as literal text. A bare _ still does not parse as an identifier, so @(_) remains literal text as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WhatsApp webhook payloads carry vendor keys that start with an underscore, such as
_vnd. Expressions traversing them stopped parsing at the underscore:The atom combinator in
Expression.Parserrequired the first character of an identifier to be a letter or digit, so._vndfailed the attribute parse and the expression was truncated afterevent.message. These keys come from the platform's own webhook enrichment, so flow authors cannot rename them; the only workaround was bracket syntax (@event.message["_vnd"]["v1"]["chat"]).Fix
Allow leading underscores in the atom grammar while still requiring at least one letter or digit, so a bare
_keeps failing to parse (@(_)remains literal text, pinned by an existing test).Behavior changes
@event.message._vnd.v1.chatevent.message, tail rendered as literal text@_missing(not in context)_missing— the@was silently swallowed by an empty expression match@_missing, the documented round-trip for unresolved variables@(_)Tests
@_foo/@__fooas variables,@event.message._vnd.v1.chatattribute chain,@(foo._bar)block form_vnd-style nested keys as string and block, unresolved@_missinground-tripmix formatandmix credo --strictclean🤖 Generated with Claude Code