Description
Hi,
We observed this issue after migrating from 3.4.2 to 4.0.1
We are using a custom converter for mapping ZonedDateTime to Date and vice versa. With the old version our aggregation worked fine, after upgrading we received the following exception:
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for CodecCacheKey{clazz=class java.time.ZonedDateTime, types=null}.
Our aggregation is using a $match stage in the pipeline right after $replaceRoot; in this $match, we compare to a ZonedDateTime vale. This should work properly, as we registered a custom converter for this type.
After some debug, we think that this was introduced by Avoid multiple mapping iterations.
Second mapping iteration is needed, because Aggregation#toPipeline method internally looses the initial RelaxedTypeBasedAggregationOperationContext after Aggregation#replaceRoot (after this stage the NoOpAggregationOperationContext is used, which doesn't seem to pick up the custom converters).
Activity
mp911de commentedon Feb 6, 2023
Would you happen to have an example handy that reproduces your use case?
banhidizoli commentedon Feb 7, 2023
My domain class looks like
And the failing aggregation is
And my custom convertor is
The custom convertor is registered like
banhidizoli commentedon Feb 15, 2023
We had to downgrade to version 4.0.0 because of this bug. Is there any estimate of when this will be fixed?
vladpetrican commentedon Mar 28, 2023
Are there any updates regarding this issue ?
csmager commentedon May 5, 2023
I've also come across this issue in as a breaking change in 3.4.7, which is the same change that causes this: #4240.
The first issue I had was because the mapping hasn't happened when this check occurs to see if the last pipeline stage is
$out
or$merge
. I get this stack trace:I then tried ensuring this stage wasn't last in the pipeline. I then ran into the issue noted here as the previous stage was
$replaceRoot
.banhidizoli commentedon Jun 12, 2023
This problem is stopping us from upgrading to latest version. @mp911de is there any plan to fix this? Or we'll have to adapt to this limitation?
pbeltechi commentedon Jan 11, 2024
This issue seems to be solved on 4.2.1 version. Just checked it today.
$replaceRoot
stage is present #4722