Skip to content

fix(application): FTP.make's args rejects bytearray/int with AttributeError instead of ProtocolError #2410

Closed

Description

@JarryShaw

Describe the bug

FTP.make's args branch (pcapkit/protocols/application/ftp.py) accepts Optional[str | bytes], but anything that isn't bytes falls through to args.encode(...). A bytearray, int, bool, or memoryview raises a bare AttributeError instead of a ProtocolError.

PR #2365 widened the sibling cmmd parameter to also accept bytearray (for the same reason #2290 treats a bare AttributeError there as a defect), but left args as it was — the gap predates #2365 and isn't new to it.

To Reproduce

from pcapkit.protocols.application.ftp import FTP
FTP(cmmd='USER', args=bytearray(b'anonymous'))
# AttributeError: 'bytearray' object has no attribute 'encode'

args=42, args=True, and args=memoryview(b'x') fail the same way. str and bytes work correctly (no regression there); cmmd=bytearray already works since #2365.

Expected behavior

Accept (bytes, bytearray) directly and .encode() only a str; anything else raises ProtocolError naming the argument, matching cmmd's current guard.

Additional context

Found and verified during this session's #1103 prose sweep (not the sweep's own scope — flagged for a dedicated fix). Widen the type annotation and Raises: docstring, and add a test alongside the existing cmmd coverage.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 28, 2026
  2. added this to the PyPCAPKit v1.5 milestone on Oct 28, 2026
  3. added
    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 28, 2026
  4. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 28, 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

    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