Currently, only the value is used and depending on use this may increase the likelyhood of discriminator clashes.
Allowing both the key and value to be used, allows for conflict free discriminators and can be safely used as the discriminator look up key rather than just the value. Doing so won't impact current users but will allow more flexibility for future users.
Was:
Patch ability to overwrite bson discriminator classes across a codec.
Minimum repro is here: https://github.com/10gen/mms/pull/105109
Context is here: https://mongodb.slack.com/archives/C0V5KNS3X/p1722569794099499
TLDR is that currently, discriminators are unique by value, which exacerbates their ability to create conflicts. It would be better if this were separated somehow by codec, or even by discriminator <key, value> pair, and if there was some type of warning or error on two entries being entered.
I don't know how complicated the first option is, but adding an error or separating by <key, value> both seem very straightforward.