Re-assigning a nested local property migrated out of NEWSESSION for a not-yet-applied object fails with a unique violation

Open
#1,932 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
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java, postgresql
Domain
database

Research direction

Start by tracing how nested local property values are copied between sessions and how migrated rows are matched during that copy; the issue does not name source files or tests. Reproduce the described NEWSESSION flow with a nested local property and check whether the object id is used to find an existing row. Done means repeating the assignment for the same object overwrites the migrated value without a unique violation, including when its class is unknown in the receiving session.

Written by the indexing model from the issue text.

Description

bug
Description

A local property declared DATA LOCAL NESTED is copied back from a NEWSESSION block into the calling session when the block's action finishes. When the action opens a form with NOWAIT, that happens right after the form is opened, so a value the form assigned in ON INIT for an object created in the new session is copied into the calling session before that object is applied. Once the form is saved and the same object is opened again from the calling session, re-assigning the same property for the same object inside the new NEWSESSION fails with a database unique violation on the session table instead of overwriting the value.

CLASS Doc;
name = DATA STRING[50] (Doc);
calc = DATA LOCAL NESTED INTEGER (Doc);

saveDoc ()  { APPLY; }

FORM doc
    OBJECTS d = Doc PANEL
    PROPERTIES(d) name, calc
    PROPERTIES() saveDoc
    EVENTS ON INIT { calc(d) <- 1; }
;

newDoc ()  { NEWSESSION { NEW d = Doc { name(d) <- 'x'; SHOW doc OBJECTS d = d DOCKED NOWAIT; } } }
editDoc (Doc d)  { NEWSESSION { SHOW doc OBJECTS d = d DOCKED NOWAIT; } }

FORM docs
    OBJECTS d = Doc
    PROPERTIES(d) READONLY name, calc
    PROPERTIES(d) editDoc TOOLBAR
    PROPERTIES() newDoc
;

Steps:

  1. Open docs, run newDoc: doc opens in its own session, ON INIT assigns calc for the new object; because of NOWAIT the NEWSESSION ends at once and copies calc, keyed by the not yet saved object, into the session of docs.
  2. In doc run saveDoc (the object is now in the database).
  3. Back in docs, refresh, select the object and run editDoc: ON INIT assigns calc for the same object again.

Result (7.0-SNAPSHOT, master build of 2026-10-18; also reported on 6.3-SNAPSHOT):

Internal Server Error: org.postgresql.util.PSQLException ERROR: duplicate key value violates unique constraint "n0_t_13_pkey"
  Detail: Key (k0)=(46138) already exists.

Expected: the assignment overwrites the migrated value, as a second assignment for the same key in one session does.

Declaring the property DATA LOCAL NESTED MANAGESESSION avoids the problem, since such a property is not migrated through NEWSESSION at all.

Reason

Any nested local property that a form assigns in ON INIT makes every later NEWSESSION edit of an object created through the new-and-show pattern fail in the calling form's session; the error names a temporary table and gives no hint of the cause.

Fix

When the values of nested local properties are copied into another session, match the rows by the object id so that a later assignment for the same object updates the migrated row instead of adding a second row with the same key, whether or not the class of the object is known in the receiving session at the time of the copy.

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.