Skip to content

ifNonempty: expression crashes instead of producing a diagnostic on malformed input #557

Description

@RonaldHensbergen

PR #555 (fixing #291) added ifNonempty:path,prefix,suffix support to cli/planner.py::resolve_expr and cli/renderer.py::_resolve_expr:

if expr.startswith("ifNonempty:"):
    path, prefix, suffix = expr[len("ifNonempty:"):].split(",", 2)
    ...

A malformed expression missing the two required commas, e.g. ${ifNonempty:config.password}, raises an uncaught ValueError: not enough values to unpack from the .split(",", 2) call. This propagates out of resolve_expr/_resolve_expr and crashes cds validate/cds test/cds render instead of producing a clean diagnostic.

Every other expression-parsing path in planner.py/renderer.py fails soft (returns None, leaving the placeholder unresolved and later caught by the existing E071 unresolved-expression check).

Task

Validate the ifNonempty: argument count before unpacking, in both planner.py and renderer.py. Either:

  • fail closed by returning None/leaving the expression unresolved (so E071 catches it), or
  • raise a proper Diagnostic with a dedicated error code describing the malformed syntax.

Add a regression test covering a malformed ifNonempty: expression (wrong number of commas) for both resolvers.

Follow-up from PR #555 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI commands and behaviorbugSomething isn't workingpriority:mediumHigh value but not blocking

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions