Skip to content

Conversation

@hs-lsong
Copy link
Collaborator

@hs-lsong hs-lsong commented Mar 4, 2024

If the a loop value is null, we should not try to get the .getClass() of it. It throws a NPE. We fixed this for single var loops, did not expect this also happens for tuples.

A bad jinjava tag can trigger it:

{% for  for row in module.specific_projects  %}

@hs-lsong hs-lsong requested a review from jasmith-hs March 4, 2024 21:52
Copy link
Contributor

@jasmith-hs jasmith-hs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good, but my concern about NullValue from #1147 (comment) and #1140 (comment) still exists

Comment on lines +219 to +226
if (
interpreter.getContext().get(loopVar) != null &&
interpreter.getConfig().getLegacyOverrides().isKeepNullableLoopValues()
) {
interpreter.getContext().put(loopVar, NullValue.INSTANCE);
} else {
interpreter.getContext().put(loopVar, null);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and L#208-214 can be extracted to a single method.

@hs-lsong hs-lsong merged commit 3fa1fa1 into master Mar 5, 2024
@hs-lsong hs-lsong deleted the fix-tuple-nulls branch March 5, 2024 14:02
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.

3 participants