$addToSet not working in update_one with upsert=True when defined in query too

On MongoDB 6 with an empty collection, running these queries won’t work:
<COLLECTION>.update_one({'list': 'a'}, {'$addToSet': {'list': 'a'}}, upsert=True)
<COLLECTION>.update_one({'list': {'$in': ['a']}}, {'$addToSet': {'list': 'a'}}, upsert=True)

Only if the document doesn’t exist, will MongoDB assume the field is a string and raise this error:
Cannot apply $addToSet to non-array field. Field named 'list' has non-array type string

These will work because MongoDB assumes the key is an array:
<COLLECTION>.update_one({'list': ['a']}, {'$addToSet': {'list': 'a'}}, upsert=True)
<COLLECTION>.update_one({'list': {'$in': ['a', 'b']}}, {'$addToSet': {'list': 'a'}}, upsert=True)

I tried searching for the solution everywhere and people say it’s solved around MongoDB 3.2~ which it probably either wrong or a fix for a different issue.
It’s probably not related to ‘pymongo’, but that’s the package I used.

Does anyone know a good solution or how to get around this issue?

<COLLECTION}.update_one( { 'list' : { '$in' : [ 'a' , null ] } },
    { '$addToSet' : { 'list' : 'a' } } ,

This workaround will not work if you want to allow null in your array. If you want to allow null you may choose any value that you know should not be in the array. The empty object {} also seems to work.

By the way it is the fact that you wrote

that gave me the idea to try with null rather than ‘b’.