LearnNewsExamplesServices
Frontmatter
id8936
titleFix: RecordFactory mapping logic not triggering for missing source keys
stateClosed
labels
bugcore
assigneestobiu
createdAtFeb 1, 2026, 5:25 PM
updatedAtFeb 1, 2026, 5:33 PM
githubUrlhttps://github.com/neomjs/neo/issues/8936
authortobiu
commentsCount1
parentIssue8930
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 1, 2026, 5:33 PM

Fix: RecordFactory mapping logic not triggering for missing source keys

Closed v12.0.0 bugcore
tobiu
tobiu commented on Feb 1, 2026, 5:25 PM

This task fixes a bug in Neo.data.RecordFactory where model fields using the mapping configuration are not populated if the field name itself is missing from the input data object.

The Issue

Currently, setRecordFields iterates over Object.entries(fields) (the input data). If a field like y2025 relies on a mapping years.2025, but y2025 is not in the input data, setRecordFields never processes it, and the mapping logic inside parseRecordValue is never triggered.

The Fix

Modify Neo.data.RecordFactory.assignDefaultValues to also handle mapped fields.

  • Iterate over the model's fields.
  • If a field has a mapping and the field key is missing in the data object:
    • Explicitly set data[fieldName] = undefined (or the default value).
  • This ensures that setRecordFields will visit the field, triggering parseRecordValue, which then correctly resolves the mapping from the source data.

Acceptance Criteria

  • Fields with mapping are correctly populated even if their key is missing in the source data.
  • The DevRank grid correctly displays data for the mapped yearly columns.
tobiu added the bug label on Feb 1, 2026, 5:25 PM
tobiu added the core label on Feb 1, 2026, 5:25 PM
tobiu added parent issue #8930 on Feb 1, 2026, 5:25 PM
tobiu assigned to @tobiu on Feb 1, 2026, 5:26 PM
tobiu referenced in commit 33c939e - "fix: RecordFactory mapping logic not triggering for missing source keys (#8936)" on Feb 1, 2026, 5:32 PM
tobiu
tobiu Feb 1, 2026, 5:32 PM

Input from Gemini 3 Pro:

✦ I have implemented the fix for RecordFactory mapping logic.

The Fix

I modified assignDefaultValues in src/data/RecordFactory.mjs. It now iterates over mapped fields and, if the field is missing from the input data object, it attempts to resolve the value using the mapping path from the data object itself.

This effectively "pre-populates" the mapped fields in the config object before setRecordFields iterates over them, ensuring that the mapping is applied and the value is set on the record.

Verification

This change ensures that y2025 (mapped to years.2025) in the DevRank model will be correctly populated from the source JSON, even though y2025 is not a key in the source JSON.

I have pushed the changes to dev.

tobiu closed this issue on Feb 1, 2026, 5:33 PM