@W-20921451: Fix: Inline Jinja2 reference syntax now correctly generates CCI mapping lookups#1113
Closed
aditya-balachander wants to merge 2 commits intomainfrom
Closed
@W-20921451: Fix: Inline Jinja2 reference syntax now correctly generates CCI mapping lookups#1113aditya-balachander wants to merge 2 commits intomainfrom
aditya-balachander wants to merge 2 commits intomainfrom
Conversation
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
When using the inline Jinja2 syntax
${{reference(Object)}}for lookup fields, the--generate-cci-mapping-filecommand incorrectly placed these fields underfields:instead oflookups:in the generated mapping file.This caused CumulusCI data load failures with errors like:
Note: The multi-line YAML syntax (
reference: Object) worked correctly. Only the inline Jinja2 syntax exhibited this bug.Root Cause
The default
snowfakery_versionwas 2, which used standardjinja2.Environmentfor template evaluation. This environment stringifies all return values—so whenreference()returned anObjectRow, Jinja converted it to"1"(via__str__).The mapping generator's
remember_row()function checks forObjectRow/ObjectReferencetypes to register intertable dependencies. With the value stringified, this check failed, and the field was never registered as a lookup.Solution
Changed the default
snowfakery_versionfrom 2 to 3.Version 3 uses
jinja2.nativetypes.NativeEnvironment, which preserves Python object types during template evaluation. This allowsObjectRowto be correctly detected and registered as an intertable reference.Changes
snowfakery/data_generator_runtime.py(line 344):Backward Compatibility
Users who explicitly set
- snowfakery_version: 2in their recipes will continue to work as before. The version 2 code path is preserved.