I came across a bug in which the bson documents were not being saved to the database. Upon further testing I found out that while saving, the dictionary keys are not checked for invalid characters (. and $).
This fix aims to resolve this problem by passing the final string through a regex pattern meant to locate precisely these two characters in field names, and replace them with safe characters.
I faced this issue when I attached the current HttpContext to the log properties. The default cookie names (.AspNet.Consent, .AspNetCore.Session, .ga) were causing the issue since I was saving them as a dictionary.
PS: This fix is also attached to a closed (yet not fully fixed issue) found here.
I came across a bug in which the bson documents were not being saved to the database. Upon further testing I found out that while saving, the dictionary keys are not checked for invalid characters (
.
and$
).This fix aims to resolve this problem by passing the final string through a regex pattern meant to locate precisely these two characters in field names, and replace them with safe characters.
I faced this issue when I attached the current HttpContext to the log properties. The default cookie names (
.AspNet.Consent
,.AspNetCore.Session
,.ga
) were causing the issue since I was saving them as a dictionary.PS: This fix is also attached to a closed (yet not fully fixed issue) found here.