[atomic-reuse] Clearing an optional field fails in the pinned Atomic lib adapter #53

Closed
opened 2026-10-19 12:06:02 +02:00 by michielbdejong · 2 comments

Affected path

Scope: atomic-reuse only for this reproduced defect.

Path Affected by this finding?
/atomic-reuse (AtomicLibDemo + AtomicTable) Yes; reproduced with pinned Atomic lib 0.40.0.
NG ORM table editor (db-table-editor-native) Not this implementation defect; it uses a different adapter.
Main db-table-editor-atomic editor on NG ORM Not this implementation defect; despite its name, its record-writing path also uses NG ORM, not AtomicTable.

This scope does not claim that the NG editors have no independent correctness problems. Reproductions used commit be8938078d97a70519a991ade8b9207d07067c5f, and current main's relevant source was checked to match. Temporary focused tests reproduced the defects; no fix or permanent regression test has been added.

Problem

Clearing an optional field produces undefined. The adapter passes the change to validated Resource.set(). In pinned @tomic/lib 0.40.0, validation rejects undefined before reaching the removal branch. The old value remains saved and the user cannot clear it.

Sources: adapter save, shared field editor, NG deletion path.

The NG path explicitly deletes a field when its new value is undefined; it does not use this failing Atomic setter path.

Reproduction

  1. Open /atomic-reuse; the initial row has Due = 2026-10-20.
  2. Edit the row, clear the optional Due field and Save.
  3. The pinned setter rejects undefined rather than removing Due.

At adapter level, using the existing setup helper in tests/unit/atomic-table.test.ts, record.save({ [due]: undefined }, record.values) rejects with Value is undefined, and the old date remains in the Store. This case was reproduced directly.

Acceptance

  • Clearing an optional date or optional text field removes the property and saves successfully. Use an explicit Resource removal operation for undefined changes; retain datatype validation for normal values.
  • Clearing a required field still fails validation and retains the draft.
  • Preserve unrelated values and failed-save retry behavior.
  • Add adapter and browser regressions for optional date/text clearing, including retry after an injected failure.

Related: #51 is collection membership; #45 is real Atomic backend work. This is a separate editing defect.

## Affected path **Scope: atomic-reuse only for this reproduced defect.** | Path | Affected by this finding? | | --- | --- | | `/atomic-reuse` (`AtomicLibDemo` + `AtomicTable`) | Yes; reproduced with pinned Atomic lib 0.40.0. | | NG ORM table editor (`db-table-editor-native`) | Not this implementation defect; it uses a different adapter. | | Main `db-table-editor-atomic` editor on NG ORM | Not this implementation defect; despite its name, its record-writing path also uses NG ORM, not `AtomicTable`. | This scope does not claim that the NG editors have no independent correctness problems. Reproductions used commit `be8938078d97a70519a991ade8b9207d07067c5f`, and current main's relevant source was checked to match. Temporary focused tests reproduced the defects; no fix or permanent regression test has been added. ## Problem Clearing an optional field produces undefined. The adapter passes the change to validated `Resource.set()`. In pinned `@tomic/lib` 0.40.0, validation rejects undefined before reaching the removal branch. The old value remains saved and the user cannot clear it. Sources: [adapter save](https://git.elfaconsortium.eu/ELFA/database-apps/src/commit/be8938078d97a70519a991ade8b9207d07067c5f/shared/atomic/atomicTable.ts#L50), [shared field editor](https://git.elfaconsortium.eu/ELFA/database-apps/src/commit/be8938078d97a70519a991ade8b9207d07067c5f/shared/ui/SchemaTable.tsx), [NG deletion path](https://git.elfaconsortium.eu/ELFA/database-apps/src/commit/be8938078d97a70519a991ade8b9207d07067c5f/shared/schema/table.ts#L60). The NG path explicitly deletes a field when its new value is undefined; it does not use this failing Atomic setter path. ## Reproduction 1. Open `/atomic-reuse`; the initial row has Due = `2026-10-20`. 2. Edit the row, clear the optional Due field and Save. 3. The pinned setter rejects undefined rather than removing Due. At adapter level, using the existing setup helper in `tests/unit/atomic-table.test.ts`, `record.save({ [due]: undefined }, record.values)` rejects with `Value is undefined`, and the old date remains in the Store. This case was reproduced directly. ## Acceptance - Clearing an optional date or optional text field removes the property and saves successfully. Use an explicit Resource removal operation for undefined changes; retain datatype validation for normal values. - Clearing a required field still fails validation and retains the draft. - Preserve unrelated values and failed-save retry behavior. - Add adapter and browser regressions for optional date/text clearing, including retry after an injected failure. Related: #51 is collection membership; #45 is real Atomic backend work. This is a separate editing defect.
Author
Owner

Upstream library report: ontola/atomic-server#2315.

The upstream issue includes a standalone reproduction on @tomic/lib@0.40.0, the observed error, the documented set(undefined) removal contract, and the matching validation-before-removal ordering inspected in current upstream develop. The newer checkout was inspected, not executed. Calling Resource.remove() explicitly remains a working local adapter workaround. This downstream issue still tracks the /atomic-reuse integration.

Upstream library report: [ontola/atomic-server#2315](https://github.com/ontola/atomic-server/issues/2315). The upstream issue includes a standalone reproduction on `@tomic/lib@0.40.0`, the observed error, the documented `set(undefined)` removal contract, and the matching validation-before-removal ordering inspected in current upstream `develop`. The newer checkout was inspected, not executed. Calling `Resource.remove()` explicitly remains a working local adapter workaround. This downstream issue still tracks the `/atomic-reuse` integration.
Author
Owner

Proposed upstream fix: https://github.com/ontola/atomic-server/pull/2317 (fixes https://github.com/ontola/atomic-server/issues/2315).

The corresponding app dependency change is #56. It pins an immutable Git commit containing a narrow backport to the compatible 0.40 library API, including the package preparation needed to install the library from the upstream monorepo. Both the app and @tomic/react resolve the same patched library. Regression coverage includes clearing optional date and text fields.

These are proposed changes; this issue remains open until the app PR is merged.

Proposed upstream fix: https://github.com/ontola/atomic-server/pull/2317 (fixes https://github.com/ontola/atomic-server/issues/2315). The corresponding app dependency change is https://git.elfaconsortium.eu/ELFA/database-apps/pulls/56. It pins an immutable Git commit containing a narrow backport to the compatible 0.40 library API, including the package preparation needed to install the library from the upstream monorepo. Both the app and @tomic/react resolve the same patched library. Regression coverage includes clearing optional date and text fields. These are proposed changes; this issue remains open until the app PR is merged.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ELFA/database-apps#53
No description provided.