Skip to content

with_codec should reject array OID collisions #173

@SeanTAllen

Description

@SeanTAllen

with_array_type rejects array_oid values that collide with registered scalar codecs (_text_codecs and _binary_codecs), but with_codec doesn't perform the reverse check against array OIDs. This produces silently unreachable dead codecs in two scenarios:

  1. Built-in array OID as scalar codec: CodecRegistry.with_codec(1007, SomeCodec)? succeeds because OID 1007 isn't in _text_codecs or _binary_codecs (it's handled via _ArrayOidMap). But decode() always takes the array path first for OID 1007, so the scalar codec is never reached.

  2. Custom array OID as scalar codec: CodecRegistry.with_array_type(9000, 600)?.with_codec(9000, SomeCodec)? succeeds because OID 9000 is in _custom_array_element_oids, not in the codec maps. Again, decode() takes the array path first.

with_codec should check _ArrayOidMap.is_array_oid(oid) and _custom_array_element_oids.contains(oid) and error on collision, matching the symmetry of with_array_type.

Found during review of #172.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions