fix: scope getDynamicEmail to referenced placeholder (fixes #53)#56
Open
rishishanbhag wants to merge 1 commit into
Open
fix: scope getDynamicEmail to referenced placeholder (fixes #53)#56rishishanbhag wants to merge 1 commit into
rishishanbhag wants to merge 1 commit into
Conversation
Resolve {{email.extract(...)}} against run-scoped inbox when steps only
use {{run.dynamicEmail}}, while preserving global inbox for cross-call OTP flows.
Author
|
Hey @panda-sandeep @unclebay143 , would you mind reviewing this when you get a chance? Fixes #53 |
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.
Summary
Fixes #53 by scoping
getDynamicEmailto the dynamic email placeholder the step set actually references, instead of always preferring the global inbox wheneverexecutionIdis set.Problem
When
runStepswas called with anexecutionId,getDynamicEmail()always returned{{global.dynamicEmail}}— even if the steps only used{{run.dynamicEmail}}.Root cause:
generateGlobalValues()always creates a{{global.dynamicEmail}}when an email domain is configured andexecutionIdis present.getDynamicEmailusedglobalValues?.["{{global.dynamicEmail}}"] || localValues["{{run.dynamicEmail}}"], so the global value was always truthy and the run-scoped fallback was never used.{{email.extract(...)}}(e.g.{{email.otp:get the OTP}}) queried the wrong inbox — the shared global address instead of the run-specific one filled in earlier in the samerunStepscall.Solution
Introduced a reference-based preference computed from the raw steps and assertions before placeholder substitution:
Changes
src/data-cache.tsDynamicEmailPreferencetype andcomputeDynamicEmailPreference()to scan steps/assertions for{{run.dynamicEmail}}and{{global.dynamicEmail}}.processPlaceholders()now returnsdynamicEmailPreferencealongside processed steps and values.getDynamicEmail()accepts a thirdpreferenceargument and routes to the correct inbox.src/index.tsdynamicEmailPreferencefromprocessPlaceholdersintogetDynamicEmailin the per-step loop.~~~ This logic needs to be fixed ...comment.src/__tests__/data-cache.test.tscomputeDynamicEmailPreference, updatedgetDynamicEmailtests for all three preference modes, and addedprocessPlaceholderscoverage for run-only, global, and no-reference step sets.