LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-ada
createdAtNov 9, 2026, 3:11 PM
updatedAtNov 9, 2026, 4:14 PM
githubUrlhttps://github.com/neomjs/neo/issues/20660
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 9, 2026, 4:14 PM

A Date record field turns null into 1970-01-01

neo-opus-ada
neo-opus-ada commented on Nov 9, 2026, 3:11 PM

Context

RecordFactory.parseRecordValue converts every non-Date value of a type: 'Date' field with new Date(value) (src/data/RecordFactory.mjs:469–470 at a4e508d25e, the 13.4.0 release commit). new Date(null) is the epoch, so a date that is absent comes back as a real-looking date. The sibling branches (Float, Int/Integer, Html, String) only run for truthy values, so they keep null.

I found this on 2026-11-08 while reading the field parser. I held it back until the 13.4 cut because the release gate said to file nothing new in Engine.

The Problem

Measured at a4e508d25e with a plain node script on the engine's unit setup. The model is {id: String, due: Date, age: Integer}:

create due:null                      Date(1970-01-01T00:00:00.000Z)
control: create age:null (Integer)   null
create, due omitted                  undefined
control: create due:ISO string       Date(2026-11-09T10:00:00.000Z)
set({due:null}) after a date         Date(1970-01-01T00:00:00.000Z)
create due:undefined                 Date(1970-01-01T00:00:00.000Z)
create due:''                        Date(Invalid)

A record cannot hold "no date":

  • Loading {due: null} stores 1970-01-01.
  • Clearing a date with record.set({due: null}) stores 1970-01-01.
  • An explicit undefined does the same, because parseRecordValue defaults value to null.

The following is inferred from the code, not run:

  • A DateField with the default emptyValue: null writes null when cleared (src/form/field/Text.mjs:1184–1185).
  • So clearing a date cell in examples/grid/cellEditing stores 1970-01-01.
  • Its renderer, new Intl.DateTimeFormat('default').format(value) (examples/grid/cellEditing/MainContainer.mjs:142, and the table twin at examples/table/cellEditing/MainContainer.mjs:140), shows 1/1/1970.
  • Intl.DateTimeFormat#format(null) also formats the epoch, so those two renderers need the empty case as well.

The Architectural Reality

  • parseRecordValue (src/data/RecordFactory.mjs:420) runs on every field write: setRecordFields (:556) for create and set, and the per-field setter (:135).
  • nullable (:462–467) is the opt-out. nullable: false refuses null with a warning and keeps the old value. Without it, null is a legal value.
  • Store#getFilterValues restates the conversion rule for raw items (autoInitRecords: false) at src/data/Store.mjs:923. A raw Date-field value that is not a Date refuses the count as noncanonical-field, because hydration would change it. That was right while hydration turned null into 1970. Once null stays null, a raw null is canonical and should count.
  • Some consumers already read "no date" as null. The header value menus keep null as a distinct option (#19720). examples/data/pipeline/MainContainer.mjs:47 renders '' for a falsy value.

Design authority: learn/guides/datahandling/Records.md:52: "nullable (Boolean): If false, the field cannot be null." So a Date field without nullable: false may be null. Today it can't be.

The Fix

  1. src/data/RecordFactory.mjs:469: convert only a value that is not null: if (type === 'date' && value != null && Neo.typeOf(value) !== 'Date'). null stays null, and an explicit undefined becomes null through the existing parameter default.
  2. src/data/Store.mjs:923: a raw null in a Date field is canonical: type === 'date' && value !== null && !(value instanceof Date). A raw undefined still refuses, because hydration turns it into null.
  3. The two cell-editing example renderers render '' for an empty value, as the pipeline example already does: ({value}) => value ? new Intl.DateTimeFormat('default').format(value) : ''.
  4. test/playwright/unit/data/RecordFactory.spec.mjs: add rows for creating with null, set({due: null}) after a date, and an explicit undefined. Add controls: an ISO string still becomes a Date, an omitted field stays undefined, and nullable: false still refuses null. test/playwright/unit/data/StoreFilterValues.spec.mjs gets the raw-null counting row.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
type: 'Date' field value (parseRecordValue) Records.md:52 null / undefined → null. A Date passes through. Any other value → new Date(value), unchanged. nullable: false still refuses null none needed: the guide already says it the unit rows above
Store#getFilterValues over raw items the same rule, restated for counting A raw null in a Date field counts as its own value Any other non-Date raw value still refuses as noncanonical-field — the counting row

Acceptance Criteria

  • A Date field created with null, or set to null after holding a date, reads null. An explicit undefined reads null.
  • An ISO string still becomes a Date, an omitted field stays undefined, and a nullable: false Date field still refuses null.
  • In a Store with autoInitRecords: false, a raw null in a Date field counts as its own value instead of refusing the count. A raw date string still refuses as noncanonical-field.
  • Both cell-editing examples render an empty date cell as empty text.
  • The RecordFactory and StoreFilterValues unit specs carry these rows, and the unit suite passes.

Out of Scope

  • '' and unparsable strings, which become an Invalid Date. Intl.DateTimeFormat#format throws RangeError on that. Whether '' means null, or whether a parse failure should be refused the way a maxLength violation is, is a design question. It gets a defect-note, not this fix.
  • Date-only ISO strings parsing as UTC midnight. #19720 already formats that case.

Avoided Traps

  • A truthy guard (&& value) like the sibling branches. It would keep 0, a valid epoch timestamp, as a number instead of a Date.

Related

#19720 (value menus keep null distinct) · #5290 and #3338 (the sibling type branches)

Live latest-open + closed sweep: checked the latest 20 open plus a closed search (Date field null 1970, RecordFactory date, parseRecordValue, date null record), and read the Out of Scope of #19720, at 2026-11-09T14:10Z. No equivalent or prior exclusion found. Backlog band: 6 open (green). MC sweep: "record field type Date null value turns into 1970-01-01 epoch, cleared date cell shows 1/1/1970", 6 results, no prior decision found. Own-assignment sweep: 0 open, none overlapping. A2A sweep: the latest 30 messages, no overlapping claim.

Ownership: self-assigned. I've held this since the 13.4 gate (2026-11-08), and I'm starting now. (Body amended 14:2xZ at intake: the Store counting rule joins the Fix, because it restates the conversion for raw items.)

Origin Session ID: b73b26a6-280c-4dc2-a4d1-c1d482593aa1 Retrieval Hint: "RecordFactory parseRecordValue Date field null epoch 1970"

tobiu referenced in commit 20afcf8 - "fix(data): a Date field keeps null, never 1970-01-01 (#20660) (#20662) on Nov 9, 2026, 4:14 PM
tobiu closed this issue on Nov 9, 2026, 4:14 PM