LearnNewsExamplesServices
Frontmatter
id9060
titleFix: RecordFactory defaultValue prevents mapping execution
stateClosed
labels
bugaicore
assigneestobiu
createdAtFeb 8, 2026, 11:31 PM
updatedAtFeb 8, 2026, 11:53 PM
githubUrlhttps://github.com/neomjs/neo/issues/9060
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 8, 2026, 11:53 PM

Fix: RecordFactory defaultValue prevents mapping execution

Closed v12.0.0 bugaicore
tobiu
tobiu commented on Feb 8, 2026, 11:31 PM

Neo.data.RecordFactory has a logic flaw in assignDefaultValues where defaultValue assignment takes precedence over mapping.

Current Logic:

if (Object.hasOwn(field, 'defaultValue')) {
    // ...
    if (data[fieldName] === undefined) {
        data[fieldName] = defaultValue; // Assigns default
    }
} else if (field.mapping) { // ELSE IF prevents mapping!
    // Mapping logic...
}

Problem: If a field has both defaultValue and mapping (e.g. {name: 'location', mapping: 'lc', defaultValue: null}), and the raw data contains the mapped key (lc) but not the target key (location):

  1. data['location'] is undefined.
  2. It enters the first if.
  3. It assigns null to data['location'].
  4. It SKIPS the else if block, so the mapping from lc never happens.

Solution: The mapping logic must run before the default value check, or they must be decoupled so that mapping can populate the field first, and then the default value fills in only if it remains undefined.

tobiu added the bug label on Feb 8, 2026, 11:31 PM
tobiu added the ai label on Feb 8, 2026, 11:31 PM
tobiu added the core label on Feb 8, 2026, 11:31 PM
tobiu assigned to @tobiu on Feb 8, 2026, 11:33 PM
tobiu referenced in commit 720605d - "fix: RecordFactory defaultValue prevents mapping execution (#9060)" on Feb 8, 2026, 11:53 PM
tobiu closed this issue on Feb 8, 2026, 11:53 PM