Skip to content

extraction: a missing engine package raises two EngineWarnings #1045

Closed

Description

@JarryShaw

Requesting an engine whose package is absent produces two EngineWarnings for one problem. Measured on main:

Extractor(..., engine='pypcap')  -> 2 EngineWarnings
  - extraction engine 'PyPCAP' not available; using default engine instead
  - engine PyPCAP (`pcap`) is not installed; using default engine instead
Extractor(..., engine='pcap_ct') -> 2 (same pair)

Cause: Extractor.import_test warns (pcapkit/foundation/extraction.py:740) and returns None. The caller's else branch then warns again (:691).

This contradicts the engines' own design. pypcap.py, pcap_ct.py and pyshark.py each return None from unsupported_reason for an absent package specifically so the import test reports it once, rather than "two warnings for one problem". PyShark and PyPCAPFile, when blocked by unsupported_reason instead, correctly produce one warning.

Fix: have exactly one of the two sites warn on the missing-package path, keeping the message that names the module. Add a test asserting exactly one EngineWarning for a missing engine package, and one for an engine blocked by unsupported_reason.

Found while reviewing #1043.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 5, 2026
  2. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 5, 2026
  3. added this to the 1.5 milestone on Oct 6, 2026
  4. moved this to Done in PyPCAPKiton Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions