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;
other.set({ms: 4});
record['address.zip'] = 4;
other.set({address: {zip: 4}}); 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
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"
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 * 1000read4002000afterrecord.ms = 4, where6000was expected. The group was right: the leaf record held4000000.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.Storewhose 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}}); // 40Measured at
3a8903fec6, whosesrc/data/RecordFactory.mjsis the one ondev(51f3d4aa25).Every
convertthat 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 insrc/data/RecordFactory.mjs: "An interceptor sees the proposed fields before conversion." Through the setter it sees a converted value.createField(), line 147) callsinstance.parseRecordValue()and passes the result tonotifyChange().notifyChange()(line 324) callssetRecordFields(), which callsparseRecordValue()for every field it is given (line 794).record.set(fields)(line 350) passes its fields tonotifyChange()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/4000and40/40, and the whole unit tier passes (6955 passed, 2 skipped, one worker).Acceptance Criteria
convertthat cannot run on its own output,record.field = valueandrecord.set({field: value})leave the same value on the record, converted once (unit arm intest/playwright/unit/data/RecordFactory.spec.mjs).recordChangeevent of a setter write carries the once-converted value and the previous value.maxLength,minLength,nullable: false) still leaves the record unchanged through the setter.devand pass with the fix; the unit tier passes.Out of Scope
convertat record creation and in Soft Hydration (#20802).applyPreparedFields()), beyond keeping its specs green.Avoided Traps
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.convertgives the same value when run twice: it hides the defect. Use one likevalue => 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:
Dateandnull, the converter's second argument).parseRecordValue: neomjs/neo-pro#185 only.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"