Skip to content

build: check_format.py crashes if executables don't exist #16504

Closed

Description

@justincely

Title: check_format.py crashes when the needed tools don't exist

Description:
paths.py can return NoneTypes if none of the required env vars are there or the binary is there. This leads to the script just crashing as the FormatChecker methods just pass this down to some stdlib functions which aren't expecting them.

Running pre-push check; to skip this step use 'push --no-verify'
  Checking format for source/server/server.cc - Traceback (most recent call last):
  File "/home/justin/codebase/envoy/support/hooks/../../tools/code_format/check_format.py", line 1258, in <module>
    ct_error_messages = format_checker.check_tools()
  File "/home/justin/codebase/envoy/support/hooks/../../tools/code_format/check_format.py", line 384, in check_tools
    check_bazel_tool('buildifier', BUILDIFIER_PATH, 'BUILDIFIER_BIN')
  File "/home/justin/codebase/envoy/support/hooks/../../tools/code_format/check_format.py", line 362, in check_bazel_tool
    bazel_tool_abs_path = self.look_path(path)
  File "/home/justin/codebase/envoy/support/hooks/../../tools/code_format/check_format.py", line 326, in look_path
    return shutil.which(executable) or ''
  File "/usr/lib/python3.8/shutil.py", line 1365, in which
    if os.path.dirname(cmd):
  File "/usr/lib/python3.8/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
error: failed to push some refs to '[email protected]:greymatter-io/envoy.git'

Repro steps:

  1. Start on a system without buildozer or buildifier or probably other tools set up.
  2. Set up the commit hooks as the documentation instructs
  3. push a commit
  4. alternatively just run the scripts

Notes
This is ubuntu 20.04 and python 3.8.

Activity

  1. added
    triage
    on May 14, 2021
  2. added and removed
    triage
    on May 14, 2021
  3. self-assigned this
    on May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions