Skip to content

fix(esp): ESP error messages lack the ESP: prefix and mostly print values without !r #2297

Closed

Description

@JarryShaw

Describe the bug
None of the ProtocolError messages in pcapkit.protocols.internet.esp follows the <prefix>: <lowercase description>: … {value!r} form that #2232 and #2257 applied to Ethernet, PCAP-NG and ARP. They have no ESP: prefix, some put "ESP" in the middle of the sentence, and most print the value bare. Even _resolve is inconsistent with itself: one branch has {value} and the other {value!r}.

Reproduction (main 9d504ead5)

>>> CipherSuite.get('ENCR_3DES')
ProtocolError: unsupported ESP encryption algorithm: ENCR_3DES; pcapkit implements ENCR_NULL, …
>>> SecurityAssociation(spi=-1)
ProtocolError: invalid SPI: -1

Expected behavior
ESP: unsupported encryption algorithm: 'ENCR_3DES'; … and ESP: invalid SPI: -1. One sweep over the module covers it: _resolve, CipherSuite.get, IntegritySuite.get, SecurityAssociation.__init__ (SPI, destination, AEAD-plus-integrity, ICV length), SecurityAssociation.unavailable / compute_icv / decrypt / encrypt / _split_key (this includes the "needs the optional "cryptography" dependency" text), ESPContext.register and the SPI and pad-length guards in ESP.make. Then update the traceback that the module docstring and esp.rst both quote. The test_esp_unit checks are assertIn substrings, so a prefix leaves them passing.

System information
Linux, CPython 3.14.9, checkout main 9d504ead5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions