Comparisons with the NULL literal (x != NULL) crash the compiler with NPEs instead of a readable error
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Reproduce the module-load or /eval case, then start with the reported paths in lsfusion.server.logics.property.classes.infer.ExClassSet.java and lsfusion.server.logics.property.PropertyFact.java. Trace where comparisons with the NULL literal are compiled and verify the EXPORT FROM and plain-property variants. Done means all shown forms produce a readable compile-time diagnostic instead of an NPE or silent NULL result.
Written by the indexing model from the issue text.
Description
Comparisons with the NULL literal (x != NULL) crash the compiler with NullPointerExceptions instead of a readable error
Environment
- lsFusion 7.0-SNAPSHOT (server build 392)
- Java 17.0.9, PostgreSQL 18, Windows 10
- reproduced via module load (startup / dry run) and via the
/evalHTTP endpoint
Context
Per language semantics, any comparison with a NULL operand propagates NULL, so an expression like expr != NULL is always NULL — it is a user error. The problem is that the platform does not reject it with a readable message: depending on where the expression is used, it either crashes the compiler with a raw NullPointerException, or (worst case) compiles cleanly and silently always evaluates to NULL.
Repro A — != NULL inside FORM FILTERS → NPE at module load
CLASS Item;
price = DATA INTEGER (Item);
FORM items 'Items'
OBJECTS i = Item
PROPERTIES(i) price
FILTERS price(i) != NULL
;
Loading this module (server start / dry run) fails with:
java.lang.NullPointerException: Cannot invoke "lsfusion.base.col.interfaces.immutable.ImMap.get(Object)" because "<parameter1>" is null
at lsfusion.server.logics.property.classes.infer.ExClassSet.lambda$0(ExClassSet.java:48)
at lsfusion.server.logics.property.classes.infer.ExClassSet.op(ExClassSet.java:48)
at lsfusion.server.logics.property.classes.infer.ExClassSet.intersect(ExClassSet.java:44)
at lsfusion.server.logics.property.Property.intersect(Property.java:354)
at lsfusion.server.logics.property.Property.inferIsInInterface(Property.java:595)
at lsfusion.server.logics.property.classes.infer.InferType.isInInterface(InferType.java:53)
at lsfusion.server.logics.property.Property.isInInterface(Property.java:576)
at lsfusion.server.logics.form.struct.ScriptingFormEntity.checkPropertyParameters(ScriptingFormEntity.java:501)
at lsfusion.server.logics.form.struct.ScriptingFormEntity.addScriptedFilters(ScriptingFormEntity.java:778)
at lsfusion.server.language.LsfLogicsParser.formFiltersList(LsfLogicsParser.java:10722)
...
The same expression posted through the /eval endpoint crashes the eval compiler with the same NPE.
Repro B — != NULL inside EXPORT FROM → NPE at script compile
EXPORT FROM a = (price(Item i) != NULL);
(any property compared to the NULL literal as an aliased EXPORT FROM expression)
java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because the return value of "lsfusion.server.logics.property.Property.getType()" is null
at lsfusion.server.logics.property.PropertyFact.createNotNull(PropertyFact.java:1310)
at lsfusion.server.logics.property.PropertyFact.createUnionNotNull(PropertyFact.java:1087)
at lsfusion.server.logics.property.PropertyFact.getFullWhereProperty(PropertyFact.java:1080)
at lsfusion.server.logics.property.PropertyFact.getFullWhereProperty(PropertyFact.java:1093)
at lsfusion.server.logics.LogicsModule.addIntegrationForm(LogicsModule.java:792)
at lsfusion.server.logics.LogicsModule.addExportPropertyAProp(LogicsModule.java:838)
at lsfusion.server.logics.language.ScriptingLogicsModule.addScriptedExportAction(ScriptingLogicsModule.java:4976)
...
The sneakier variant — compiles cleanly, silently always NULL
The same comparison used as a plain module property does not crash at all:
isSet (Item i) = price(i) != NULL; // always NULL, no error, no warning
It compiles, and every dependent filter/condition silently never fires — no diagnostic anywhere. This is arguably worse than the NPEs: I hit this in a real project (isScheduled, hasNotes, search matchers written as x != NULL AND …) and the only symptom was silently empty lists.
Expected behavior
- A readable compile-time error or warning wherever an equality/inequality operand is the
NULLliteral, e.g. "expr != NULLis always NULL by NULL-propagation; useIF expr THEN TRUEfor a non-null check orNOT exprfor a null check". - No
NullPointerExceptionfrom the parser/inference paths (Repro A and B) — a user mistake in an expression should surface as a message, not a stack trace.
Since the pattern (= NULL / != NULL against the literal) is statically recognizable, a single check in the expression compiler would cover all three variants above.
Workaround
isSet (Item i) = IF price(i) THEN TRUE; // non-null check
isNull (Item i) = NOT price(i); // null check
- 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