Skip to content

fix: skip ignored members before reading source property#104

Merged
phramz merged 1 commit intomainfrom
fix/skip-ignored-members-before-source-read
Mar 6, 2026
Merged

fix: skip ignored members before reading source property#104
phramz merged 1 commit intomainfrom
fix/skip-ignored-members-before-source-read

Conversation

@phramz
Copy link
Copy Markdown
Contributor

@phramz phramz commented Mar 6, 2026

Summary

  • Fixes spurious WARNING logs ("Cannot access source property") emitted for every mapping member marked with ignore() when the corresponding property doesn't exist on the source object
  • Moves the isIgnored() check to the top of the mapping loop in mapType(), before memberSourceValueFor() is called
  • Removes the now-redundant isIgnored() guard inside memberDestinationValuePut()

Root cause

The mapping loop in AutoMapper::mapType() iterated all destination members and immediately attempted to read the source property. The isIgnored() check only existed inside memberDestinationValuePut(), which was never reached when the source read failed — causing a warning + continue on every ignored member without a matching source property.

Test plan

  • Added testIgnoredMemberWithNoSourcePropertyDoesNotLogWarning — verifies no warning is logged for ignored members with missing source properties
  • Added testIgnoredMemberSkipsSourceReadAndDestinationWrite — verifies ignored members retain their default value when using map()
  • Full test suite passes (141 tests, 387 assertions)

🤖 Generated with Claude Code

Ignored members were triggering spurious WARNING logs ("Cannot access
source property") when the corresponding property did not exist on the
source object. The isIgnored() check only existed inside
memberDestinationValuePut(), which was never reached when the source
read failed. Move the check to the top of the mapping loop so ignored
members are skipped before any source access attempt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@phramz phramz merged commit f08ec50 into main Mar 6, 2026
10 checks passed
@phramz phramz deleted the fix/skip-ignored-members-before-source-read branch March 6, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant