A value passed to a property under CONSTRAINT ... CHECKED BY from a custom component is silently written as NULL when it is outside the filter

Open
#1,923 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend

Research direction

Start by tracing how a pushed value is resolved against a dialog input's offered value list, including CHECKED BY filters, then follow how the default change action handles a missing value. The issue does not name files or tests, so locate those entry points in the Java platform code. Done when an out-of-list value cancels the change, preserves the previous value, and reports the constraint or a generic error.

Written by the indexing model from the issue text.

Description

bug
Description

A property with a custom-class value is drawn with a custom component, and the component passes a new value through its controller (controller.change(id)). The property is listed in the CHECKED BY block of a constraint:

CLASS PTask 'Task';
CLASS PStatus 'Status';

name 'Name' = DATA STRING[50] (PStatus);
name 'Name' = DATA STRING[50] (PTask);
status 'Status' = DATA PStatus (PTask);
allowed 'Allowed' = DATA BOOLEAN (PTask, PStatus);
statusName 'Status name' (PTask t) = name(status(t));

CONSTRAINT status(PTask t) AND NOT allowed(t, status(t))
    CHECKED BY status[PTask]
    MESSAGE 'Status not allowed for the task';

FORM probeChecked 'Probe checked form'
    OBJECTS t = PTask
    PROPERTIES(t) name, status CUSTOM 'probeCustomStatus', statusName
;

Data: statuses New, Done, Blocked; a task with status = New and allowed = TRUE for New and Done only. The render function stores the controller it receives, and the test calls controller.change(<id>) on it (the same call a kanban board makes when a card is dropped into a column).

Actual:

  • controller.change(<id of Done>) (inside the filter): the status becomes Done, as expected.
  • controller.change(<id of Blocked>) (outside the filter): the status becomes NULL. The previous value New is lost, nothing is shown to the user, and the constraint is not violated, so the change can be applied.

Expected: a value outside the CHECKED BY filter is not written: the change is refused (the previous value stays) and the user sees the constraint message, or at least an error. Writing NULL turns a filter that exists to prevent an invalid value into a data loss.

The same happens with any value that reaches the default change action of such a property without the selection dialog. A form-level ON CHANGE handler with INPUT s = PStatus DO { IF allowed(t, s) THEN status(t) <- s; ELSE MESSAGE ...; } is the workaround: it receives the passed id as the object and can refuse it.

Fix

When the value pushed into a dialog input with a value list is not found in the list (the CHECKED BY filters included), cancel the request instead of resolving it to NULL: the change is then not executed, and the constraint message (or a generic "value is not allowed" message) is shown.

Reason

The pushed value is resolved by looking it up in the list of offered values, which already carries the CHECKED BY filters; a value that is not found resolves to NULL, and the default change action writes the resolved value as it is.

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.