Skip to content

mini_parser: trailing whitespace and malformed conditions raise IndexError/KeyError #65

Open

Description

@xupinjie

Summary

The condition mini-parser raises unexpected exceptions for several inputs. In particular, adding trailing whitespace to an otherwise valid condition causes an IndexError. A missing closing parenthesis and adjacent operands raise IndexError and KeyError instead of a useful syntax error. These exceptions propagate through AnnotationElementConditionEval(condition=...).

Reproduction

from accvlab.dali_pipeline_framework.internal_helpers.mini_parser import Parser

for condition in ("x = a", "x = a ", "x = a\u3000", "x = (a", "x = a b"):
    try:
        Parser(condition).parse()
        print(repr(condition), "OK")
    except Exception as exc:
        print(repr(condition), type(exc).__name__, str(exc))

Observed at commit 213e5c8:

Condition Result
x = a Parses successfully
x = a IndexError: string index out of range
x = a\u3000 IndexError: string index out of range
x = (a IndexError: list index out of range
x = a b KeyError: 'variable'

Expected behavior

Trailing whitespace should not change the result of a valid condition. Malformed conditions should raise a clear ValueError rather than exposing internal IndexError or KeyError exceptions.

Source analysis

Please add regression coverage for these inputs when fixing the parser.

Activity

  1. xupinjie commented on Oct 12, 2026

    @xupinjie
    CollaboratorAuthor

    @RmSchaffert can help fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions