Report a form object without a value in `SHOW`, `PRINT`, `EXPORT`, `JSON` and `JSONTEXT` instead of a NullPointerException

Open
#2,015 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
compilers

Research direction

The behavior is in how the SHOW/PRINT/EXPORT/JSON/JSONTEXT operators are parsed and validated: locate the parser code that reads the OBJECTS block and the class-form usage of these operators, then find where a missing = expression is currently left unchecked. Use the fix for DIALOG in #1979 as the model for how the error should be raised, and reuse the existing operator error reporting so the message carries the position. Done means the sample module from the issue fails with a clear "form object needs a value" error instead of a NullPointerException, and the same for the JSON/JSONTEXT expressions and class-forms.

Written by the indexing model from the issue text.

Description

bug
Description

In the SHOW and PRINT operators, in the EXPORT of a form and in the form variants of JSON and JSONTEXT, every object listed in OBJECTS needs a value (OBJECTS s = expression), and so does the object of the class-form (SHOW EDIT Sku = expression). Only DIALOG allows an object to be listed without one. When the value is omitted in the other operators, it is not reported as an error of the operator: loading the module fails with a NullPointerException.

MODULE ShowProbe;

CLASS Sku;
num = DATA INTEGER (Sku);
FORM sku OBJECTS s = Sku PANEL PROPERTIES(s) num;

open () {
    FOR num(Sku s) = 1 DO SHOW sku OBJECTS s;
}
Error during parsing at ShowProbe:7:44
java.lang.NullPointerException

PRINT sku OBJECTS s;, EXPORT sku OBJECTS s JSON;, the expressions JSON (sku OBJECTS s) and JSONTEXT (sku OBJECTS s), and the class-forms SHOW EDIT Sku;, SHOW LIST Sku;, PRINT LIST Sku;, EXPORT LIST Sku JSON; fail the same way. The /eval and /eval/action probes returned HTTP 500 with the same exception. When internal error details are hidden, the response omits the exception text. With the value given (SHOW sku OBJECTS s = s;) the module loads.

Reproduced on 7.0-SNAPSHOT (master). SHOW sku OBJECTS s; fails the same way on 6.3-SNAPSHOT.

Reason

In an application module, one such operator prevents the server from starting. In an evaluated script, it fails the request. The error gives a position but does not say that a value is missing. The operator is easy to write: inside a loop over s, OBJECTS s reads as "the object s of the form takes the loop's s", and the IDE does not mark it. A similar case of DIALOG was fixed in #1979.

Fix

Report it as a regular error of the operator, saying that the form object needs a value (= expression).

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lsfusion/platform

All issues in lsfusion/platform

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.