LearnNewsExamplesConnect
Frontmatter
assigneesbardrop
createdAtNov 13, 2026, 3:11 AM
updatedAtNov 13, 2026, 2:56 PM
githubUrlhttps://github.com/neomjs/neo/issues/20848
authorneo-opus-vega
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined1
signals[]
blockedBy[]
blocking[]
closedAtNov 13, 2026, 2:56 PM

A record field's setter converts its value twice

Closed v14.0.0/archive-v14-0-0-chunk-1 bughelp wantedgood first issueaicore
neo-opus-vega
neo-opus-vega commented on Nov 13, 2026, 3:11 AM

Context

Found on 2026-11-13 while writing a unit arm for neomjs/neo-pro#185. A grouped sum over a field with convert: value => value * 1000 read 4002000 after record.ms = 4, where 6000 was expected. The group was right: the leaf record held 4000000.

The Problem

Assigning a field through its setter parses the value twice. record.set() parses it once.

Reproducer, a unit probe on a Neo.data.Store whose model has {name: 'ms', convert: value => value * 1000} and a nested {name: 'address', fields: [{name: 'zip', convert: value => value * 10}]}:

record.ms = 4;                  // record.ms === 4000000
other.set({ms: 4});             // other.ms  === 4000

record['address.zip'] = 4;      // 400, and recordChange carries {name: 'address.zip', oldValue: 10, value: 400}
other.set({address: {zip: 4}}); // 40

Measured at 3a8903fec6, whose src/data/RecordFactory.mjs is the one on dev (51f3d4aa25).

Every convert that cannot run on its own output is affected: a unit conversion, a parser. Type coercion hides it, because parsing a parsed value gives the same value.

The Architectural Reality

Design authority: notifyChange()'s JSDoc in src/data/RecordFactory.mjs: "An interceptor sees the proposed fields before conversion." Through the setter it sees a converted value.

  • The field setter (createField(), line 147) calls instance.parseRecordValue() and passes the result to notifyChange().
  • notifyChange() (line 324) calls setRecordFields(), which calls parseRecordValue() for every field it is given (line 794).
  • record.set(fields) (line 350) passes its fields to notifyChange() as given, so they are parsed once.

The Fix

The setter passes the assigned value to notifyChange() as it is. setRecordFields() stays the one place that parses a written value.

I tried that one-line change before filing: the reproducer above reads 4000/4000 and 40/40, and the whole unit tier passes (6955 passed, 2 skipped, one worker).

Acceptance Criteria

  • For a field with a convert that cannot run on its own output, record.field = value and record.set({field: value}) leave the same value on the record, converted once (unit arm in test/playwright/unit/data/RecordFactory.spec.mjs).
  • The same holds for a nested field, whose setter is created with a path.
  • The recordChange event of a setter write carries the once-converted value and the previous value.
  • A value the field refuses (maxLength, minLength, nullable: false) still leaves the record unchanged through the setter.
  • The new arms fail on dev and pass with the fix; the unit tier passes.

Out of Scope

  • convert at record creation and in Soft Hydration (#20802).
  • Prepared field admission (applyPreparedFields()), beyond keeping its specs green.

Avoided Traps

  • Skipping the parse inside setRecordFields() for a setter write: set() and the setter would then need a flag to tell them apart, and the single parse point is lost.
  • A reproducer whose convert gives the same value when run twice: it hides the defect. Use one like value => value * 1000.

Related

#20802, #20846 (where it surfaced), neomjs/neo-pro#185.

unowned-rationale: Ready for a contributor; maintainers provide planning and review.

Live latest-open + closed sweep, 2026-11-13 at 02:10Z; no equivalent or prior exclusion found:

  • Latest 20 of 30 open issues (orange band; no owning ticket or epic for a record's write path).
  • Closed searches: "record setter convert twice", "parseRecordValue", "convert applied twice record field", "double conversion record set". Same-surface hits #20802, #20660 and #8403 decide other paths (creation, Date and null, the converter's second argument).
  • Organization-wide open search for parseRecordValue: neomjs/neo-pro#185 only.
  • A2A of the last hour: no claim on the record write path.

MC sweep: "record field assignment converts the value twice; record.field = value differs from record.set()", 5 results, no prior decision found. Own-assignment sweep: 2 open (#20846, #20667), none overlapping.

Origin Session ID: 77142ae6-f1af-4b57-aebc-cd4212de36aa Retrieval Hint: "record field setter parseRecordValue twice convert non-idempotent record.set once"

bardrop
bardrop Nov 13, 2026, 4:00 AM

I'd like to take this one: the setter passes the raw value to notifyChange() and setRecordFields() stays the only parse point, plus the unit arms from the acceptance list.

Disclosure, per CONTRIBUTING §5: this is done with an AI agent (Claude Code, Claude Opus 5.5).

  • 2026-11-13T03:00:59Z @github-actions assigned to @bardrop

@github-actions - 2026-11-13T03:01:00Z

Thanks for claiming this, @bardrop, and welcome! Assigned to you — you can start now.

Your claim reserves this issue for 3 days (any comment here resets the clock; we still merge the first approve-worthy PR if another lands first or a claim goes quiet).

An automatic reply. How claims work [QUARANTINED_URL: github.com]

bardrop cross-referenced by PR #20854 on Nov 13, 2026, 4:06 AM
tobiu referenced in commit e0fa9f0 - "fix(data): field setter converts the assigned value once (#20848) (#20854) on Nov 13, 2026, 2:56 PM
tobiu closed this issue on Nov 13, 2026, 2:56 PM