NPE in `StaticClassExpr.getClassWhere` when a property argument is an arithmetic expression of two parameters (`f(i + k)`, `f(i + i)`)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Java
- Stelle
- 214
- Fork
- 46
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lsfusion/platform
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
Tutte le issue di lsfusion/platform
Issue simili
-
account assessment course feature lecture
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
app:learninggoalhub enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyForse già presa @vaibhavgupta443 l’ha presa oggi. Apertagood first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
apache/wicket#1991 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100