Skip to content

Ignored unknown source property error, but property exist. #2743

@Trafo

Description

@Trafo

From my perspective, I found a bug, because of the inconsistent behaving of ignoreUnmappedSourceProperties.

I defined these classes:

data class Inside(val value : String)
data class InsideDto(val value : String)
data class Problem(val problem : String)
data class ProblemDto(val problem : String)
data class Outside(val inside : Inside, val problem : Problem)
data class OutsideDto(val insideDto : InsideDto, val problem : ProblemDto)

Inside of a Mapper which has this Config:

@MapperConfig(
    componentModel = "spring",
    unmappedSourcePolicy = ReportingPolicy.ERROR,
    unmappedTargetPolicy = ReportingPolicy.ERROR
)

I declared:

@Mapper(config = MapstructConfig::class)
interface Converter {
    @BeanMapping(ignoreUnmappedSourceProperties = ["inside"])
    fun test(
        outside: Outside,
        insideDto: InsideDto
    ): OutsideDto
}

this throws the following error:
error: Ignored unknown source property: "inside". public abstract [placeholder].OutsideDto test(@org.jetbrains.annotations.NotNull

I found a workaround. I just have to add an extra mapper declaration inside of my Converter for the Problem mapping:

fun solution(problem: Problem) : ProblemDto

In this case, everything works. For me, this looks like a bug, because it is not consistent behaviour.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions