Why is CodingUserInfoKey's rawValue initializer failable?

I have some code like this:

extension SomeType: Decodable {
    private static let someKey = CodingUserInfoKey(rawValue: "SomeType.someKey")!

    static func decoder(value: SomeNecessaryValueForDecoding) -> JSONDecoder {
        let decoder = JSONDecoder()
        decoder.userInfo = [
            SomeType.someKey: value,
        ]
        return decoder
    }
}

As far as I can tell, this will never actually fail. Is there a reason the initializer is failable? Maybe there's a non-failable initializer I've missed, or something I'm generally misunderstanding about this type?

This was largely a mistake in the implementation; please see SR-6753 for background. This is something that might be fixable, keeping in mind source stability requirements.

1 Like

Is there any interest in changing this? I don’t see how making an initializer that already never returns nil nonfailable could cause breaking changes (maybe compiler warnings related to unwrapping), and it remove a source of some anxiety from functionality that is used quite often.

Failing that, the documentation should at least be changed to indicate that it never returns nil.