Skip to content

@W-20921451: Fix: Inline Jinja2 reference syntax now correctly generates CCI mapping lookups#1113

Closed
aditya-balachander wants to merge 2 commits intomainfrom
W-20921451/default-snowfakery-version-2-to-3
Closed

@W-20921451: Fix: Inline Jinja2 reference syntax now correctly generates CCI mapping lookups#1113
aditya-balachander wants to merge 2 commits intomainfrom
W-20921451/default-snowfakery-version-2-to-3

Conversation

@aditya-balachander
Copy link
Copy Markdown
Contributor

Problem

When using the inline Jinja2 syntax ${{reference(Object)}} for lookup fields, the --generate-cci-mapping-file command incorrectly placed these fields under fields: instead of lookups: in the generated mapping file.

This caused CumulusCI data load failures with errors like:

MALFORMED_ID: Account ID: id value of incorrect type: 1

Note: The multi-line YAML syntax (reference: Object) worked correctly. Only the inline Jinja2 syntax exhibited this bug.

Root Cause

The default snowfakery_version was 2, which used standard jinja2.Environment for template evaluation. This environment stringifies all return values—so when reference() returned an ObjectRow, Jinja converted it to "1" (via __str__).

The mapping generator's remember_row() function checks for ObjectRow/ObjectReference types 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_version from 2 to 3.

Version 3 uses jinja2.nativetypes.NativeEnvironment, which preserves Python object types during template evaluation. This allows ObjectRow to be correctly detected and registered as an intertable reference.

Changes

snowfakery/data_generator_runtime.py (line 344):

# Before
snowfakery_version = self.options.get(
    "snowfakery.standard_plugins.SnowfakeryVersion.snowfakery_version", 2
)

# After
snowfakery_version = self.options.get(
    "snowfakery.standard_plugins.SnowfakeryVersion.snowfakery_version", 3
)

Backward Compatibility

Users who explicitly set - snowfakery_version: 2 in their recipes will continue to work as before. The version 2 code path is preserved.

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.

1 participant