Skip to content

fix: shutil.which() return value not checked before os.path.dirname() #5412

Description

@Manhhoangvp95

Description

On non-Windows platforms, shutil.which("kubectl") returns None if the
executable is not found. The code then calls os.path.dirname(full_path)
which will raise TypeError: expected str, bytes or os.PathLike object, not NoneType.
This will crash at runtime when kubectl is not installed.

Severity: high
File: installer/common/file_utils.py

Expected Behavior

The code should handle this case properly to avoid unexpected errors or degraded quality.

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