Skip to content

SUM over a list containing null throws instead of skipping the null #244

Description

@cesarParra

SUM throws a runtime error when the list contains a null, rather than skipping it.

Repro

No org data needed:

expression.Evaluator.run('SUM([1, null, 3])', someId);   // runtime error
expression.Evaluator.run('SUM([1, 2, 3])', someId);      // => 6

Expected: 4, treating null as absent — or at minimum an error that names the problem.
Actual: a runtime error with an empty message (see the separate issue about error messages).

Why it matters

This is the normal shape of a rollup over records, where an optional currency or number field is
blank on some rows:

Opportunities -> WHERE(IsClosed = false) -> MAP(Amount)

One opportunity with no Amount and the whole total fails. Because the failure is a hard error
rather than a skipped row, a formula that works today starts failing when someone saves a record
with a blank field — and with no message, there is nothing to indicate which field or row caused
it.

Guarding every rollup with -> WHERE(Field != null) works, but it has to be remembered for every
nullable field, and forgetting is silent until the data changes.

AVERAGE and similar aggregates are presumably affected the same way.

Environment

Expression 1.52.0.1, Developer Edition scratch org.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions