Skip to content

Resolve attribute path before comparing list/map elements in conditionals - #3488

Open
m86hussein wants to merge 1 commit into
flyteorg:masterfrom
m86hussein:fix/6473-conditional-list-index
Open

m86hussein wants to merge 1 commit into
flyteorg:masterfrom
m86hussein:fix/6473-conditional-list-index

Conversation

@m86hussein

Copy link
Copy Markdown

Why

Indexing into a list or map (e.g. xs[0]) produces a promise whose index is stored in attr_path, while val still holds the whole collection. ComparisonExpression inspected val.scalar directly, so comparing a list element — for example xs[0].is_none() inside a conditional — raised:

AttributeError: 'NoneType' object has no attribute 'union'

because a collection literal has no scalar.

What

  • Add a helper that resolves a ready promise's attr_path (list/map indexing) down to the leaf literal.
  • ComparisonExpression now inspects the resolved leaf for both operands, guards against a None scalar, and keeps the resolved leaf for primitive elements so local eval() works.
  • This code path only runs during local execution (is_ready), so remote serialization (unready promises -> variable references) is unaffected.

Tests

Added test_condition_with_list_index covering a None list element (is_none() -> True branch), a non-None element (-> else branch), and a primitive int element comparison.

Related issue

Fixes flyteorg/flyte#6473

…nals

Indexing into a list or map (e.g. xs[0]) produces a promise whose index is stored in attr_path while val still holds the whole collection. ComparisonExpression inspected val.scalar directly, so comparing a list element (such as xs[0].is_none()) raised AttributeError: 'NoneType' object has no attribute 'union' because a collection literal has no scalar. Resolve the attr_path to the leaf literal before inspecting the value, guard against a None scalar, and keep the resolved leaf for primitive elements so local evaluation works. This path only runs during local execution (is_ready), so remote serialization is unaffected.

Fixes flyteorg/flyte#6473

Signed-off-by: m86hussein <m86hussein@gmail.com>
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.

[BUG] is_none() does not work with list inputs as conditionals

1 participant