The get_codec function modifies its argument, popping the "id" key. This can lead to surprising behaviour such as:
config = {"id": "json"}
codec = get_codec(config) # Works
codec = get_codec(config) # fails.
I suggest adding config = dict(config) at the start of the function. The performance implications should be minimal I think.