Skip to content

Add startup validation for required LFTP config fields #310

@nitrobass24

Description

@nitrobass24

Problem

Controller uses self.__context.config.lftp fields (remote_address, remote_path, local_path, etc.) that are typed as Optional[str] because they start as None before the user configures them. Throughout the controller, these are passed with # type: ignore[arg-type] comments to suppress type errors — over a dozen instances scattered across _create_pair_context, __spawn_move_process, and the main loop.

This means:

  • If a required field is missing at runtime, the failure happens deep in the call stack (e.g., os.path.join(None, ...)) with an unclear error
  • Static type checking is bypassed via type: ignore, defeating the purpose of Pyright enforcement

Proposed Solution

Add a Controller._validate_config() method (or similar) called early in Controller.start() that:

  1. Asserts required LFTP fields are non-None (remote_address, remote_username, remote_path, local_path, remote_port, etc.)
  2. Raises a clear ConfigError or ValueError with a user-friendly message if any are missing
  3. Once validated, the type: ignore[arg-type] comments on those fields can be removed since the runtime contract is explicit

Context

Identified during PR #309 review. Deferred as it's a broader refactor beyond the scope of a patch release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v0.14.3Targeted for v0.14.3 release

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions