NPE in `StaticClassExpr.getClassWhere` when a property argument is an arithmetic expression of two parameters (`f(i + k)`, `f(i + i)`)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start with StaticClassExpr.getClassWhere at StaticClassExpr.java:23 and trace how FormulaExpr.getStaticClass() supplies the class for property arguments. Reproduce with the provided line(i + i) example using nonempty data; empty data masks the failure. Done means arithmetic arguments no longer throw an NPE and the date arithmetic cases return the expected value or type.
Written by the indexing model from the issue text.
Description
Steps to reproduce
Run as an eval script (POST /eval, module mode with run()), or put it into any module and call the action:
line = DATA LOCAL STRING (INTEGER);
run() {
line(1) <- 'a';
line(2) <- 'b';
EXPORT JSON FROM c = (GROUP SUM 1 IF line(INTEGER i) AND line(i + i));
}
Expected
{"c":1} (for i = 1, line(2) is set).
Actual
java.lang.NullPointerException: Cannot invoke "lsfusion.server.logics.classes.ConcreteClass.inSet(lsfusion.server.logics.classes.user.set.AndClassSet)" because the return value of "lsfusion.server.data.expr.classes.StaticClassExprInterface.getStaticClass()" is null
at lsfusion.server.data.expr.classes.StaticClassExpr.getClassWhere(StaticClassExpr.java:23)
at lsfusion.server.data.expr.classes.StaticClassExpr.getClassWhere(StaticClassExpr.java:26)
at lsfusion.server.data.where.classes.ClassWhere.mapClasses(ClassWhere.java:98)
at lsfusion.server.data.table.Table$Join$IsIn.calculateClassWhere(Table.java:548)
at lsfusion.server.data.where.AbstractWhere.getClassWhere(AbstractWhere.java:173)
at lsfusion.server.data.where.DataWhere.create(DataWhere.java:89)
at lsfusion.server.data.table.Table$Join.getWhere(Table.java:410)
at lsfusion.server.data.table.Table$Join$IsIn.translate(Table.java:525)
at lsfusion.server.data.expr.where.ifs.IfExpr.translate(IfExpr.java:204)
at lsfusion.server.data.query.translate.QueryTranslateJoin.getExpr(QueryTranslateJoin.java:28)
at lsfusion.server.data.query.translate.RemapJoin.getExpr(RemapJoin.java:21)
at lsfusion.server.logics.property.Property.getQueryExpr(Property.java:2398)
...
Scope
Checked on 44 variants. The results on 6.3 and 7.0 are identical; the stored property was checked on 7.0 only.
Fails
- Argument forms:
line(i + k),line(k + i),line(i - k),line(i * k),line(i (+) k), andline(i + i)with a single parameter. - It fails however the second parameter is bounded:
iterate(k, 1, 2), another local property, ork >= 1 AND k <= 2. It fails even for an emptyiterate(k, 1, 0). - Contexts:
GROUP SUM,GROUP MIN,EXPORT ... WHERE,<- ... WHERE,FOR. - Key classes:
INTEGER,LONG,NUMERIC,DOUBLE,STRING(lineS(a + b)), and mixedINTEGER+LONG. - Properties: any
DATA LOCAL, a storedDATAproperty, and a calculated property over it (len(INTEGER x) = length(line(x))).
Works - Arguments with a constant or a cast:
line(i + k + 1),line(i + k + 0),line(INTEGER(i + k)),line(i + 1),line(k + 1); the same withNUMERICkeys and with strings (lineS(a + b + '')). - A constant of another class than the key: a
LONGorNUMERICkey withline(i + 1), whereiisINTEGER. i + koutside a property argument:i + k > 0,GROUP MAX (i + k).- A pure formula property without a table:
sq(INTEGER x) = x * x, thensq(i + k); alsosum(d, k)for dates.
Masked on empty data: if the local property has no rows, there is no error and the result is 0, so a test on empty data passes.
Related: date arithmetic in 7.0
In 7.0, + and - work for dates, and the value of d + 1 is correct. But its class is INTEGER: e = d + 1 with a DATE e does not compile (value of class 'DATE' is not comparable with value of class 'INTEGER'). As an argument of a property with a DATE key, it gives an empty result without any error:
lineD = DATA LOCAL STRING (DATE);
run() {
lineD(2026_10_01) <- 'a';
lineD(2026_10_02) <- 'b';
lineD(2026_10_03) <- 'c';
EXPORT JSON FROM d = DATE d, v = (d + 1), plus1 = lineD(d + 1), cast1 = lineD(DATE(d + 1)) WHERE lineD(d);
}
Expected: plus1 = b and c for 2026-10-01 and 2026-10-02, the same as cast1.
Actual: v is correct (2026-10-02, 2026-10-03, 2026-10-04), cast1 = b, c, plus1 is empty in every row.
lineD(d + k),line(a - b)(DATE−DATE): the same NPE.lineD(d + 1),lineD(d - 1),lineD(d + k + 0): empty result, no error.lineD(DATE(d + k)),lineD(sum(d, k)): correct.
Possible cause
FormulaExpr.getStaticClass() calls getStaticClass(null), which takes getSelfType(), the type computed without the classes of the keys. For an expression built only from keys, this type is null, and StaticClassExpr.getClassWhere calls inSet on it without a null check. With a constant, the type seems to come from the constant, so d + 1 gets INTEGER instead of DATE, and the class check against a DATE key fails. This code is the same in 6.3 and 7.0.
Suggested label: bug
- Dominant language
- Java
- Stars
- 214
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsfusion/platform
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in lsfusion/platform
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100