Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Collection Membership operator can return unintuitive results if collection has mix of types

Open
#1,240 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start with CollectionMembershipOperator.java, especially lines 34-47, and trace how the membership and “is containing” operations coerce mixed-type collections. Reproduce the examples from the issue, then establish the intended comparison behavior before identifying the regression coverage needed to show that null, numeric, string, and boolean values are handled consistently.

Written by the indexing model from the issue text.

Description

Since the CollectionMembershipOperator coerces the type of the item being tested to the first (or first non-null) element in the list, it can lead to unexpected/unintuitive results.

https://github.com/HubSpot/jinjava/blob/af0819ac4cfc8fb99cfa9b7ccddfbfd251946f9d/src/main/java/com/hubspot/jinjava/el/ext/CollectionMembershipOperator.java#L34-L47

{{ null in [null, 1, 2] }} {# true #}
{{ null in [1, null, 2] }} {# false - null converted to 0; no 0 in list #}
{{ null in [1, null, 2, 0] }} {# true - because of the 0 in the list, not the null #}
{{ null in [0, 1, 2] }} {# true #}

{{ 1 in ['1', 2 ] }} {# true - 1 converted to '1' #}
{{ 2 in ['1', 2 ] }} {# false - 2 is converted to '2', no '2' in list #}
{{ 1 in [false, 1] }} {# false - 1 converted to true #}
{{ 1 in [true, 0] }} {# true #}
{{ 1 in [null, 'abc', 1] }} {# false #}

{{ '' in [1, '', 2] }} {# false #}
{{ '' in [0, 1, 2] }} {# true #}

(The same applies to is containing, e.g. [false, 1] is containing 1 is false)

Dominant language
Java
Stars
785
Forks
184
Avg merge
6d 22h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HubSpot/jinjava

All issues in HubSpot/jinjava

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.