cloudflare/cloudflared · error · Exception

the argument path must be a directory

Error message

the argument path must be a directory

What it means

main validates that the --path argument points to an existing directory containing the release binaries; if it is not a directory, this exception is raised and caught by the top-level handler, which logs it and exits with status 1. It guards against passing a file path, a nonexistent path, or an empty path value.

Source

Thrown at github_release.py:309

                logging.error("dryrun failed")
            return
        else:
            client = Github(args.api_key)
            repo = client.get_repo(CLOUDFLARED_REPO)

            if os.path.isdir(args.path):
                onlyfiles = [f for f in listdir(args.path) if isfile(join(args.path, f))]
                for filename in onlyfiles:
                    binary_path = os.path.join(args.path, filename)
                    assert_asset_version(binary_path, args.release_version)
                release = get_or_create_release(repo, args.release_version, args.dry_run, args.draft)
                for filename in onlyfiles:
                    binary_path = os.path.join(args.path, filename)
                    upload_asset(release, binary_path, filename, args.release_version, args.kv_account_id, args.namespace_id,
                    args.kv_api_token)
                    move_asset(binary_path, filename)
            else:
                raise Exception("the argument path must be a directory")

    except Exception as e:
        logging.exception(e)
        exit(1)

main()

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Check the path exists and is a directory before invoking the script: test -d "$PATH" || exit 1.
  2. Pass the correct directory containing the built binaries via --path.
  3. Fix the CI working directory or build step so the artifact directory is present at the given path.
  4. Add an explicit pre-check in main (os.path.isdir) for a clearer error message including the actual path.

Example fix

// before
raise Exception("the argument path must be a directory")
// after
raise Exception(f"the argument path must be a directory: {args.path!r}")
Defensive patterns

Strategy: validation

Validate before calling

import argparse, os
p = argparse.ArgumentParser()
p.add_argument("--path", required=True)
args = p.parse_args()
if not os.path.isdir(args.path):
    p.error(f"--path must be an existing directory: {args.path}")

Try / catch

try:
    main()
except SystemExit as e:
    if e.code != 0:
        logging.error("release failed, see logs above")

Prevention

When it happens

Trigger: Running the release script with --path pointing to a regular file instead of a directory, a path that does not exist, or omitting/misspelling the flag so args.path is empty or invalid.

Common situations: CI configs passing a single artifact file rather than a folder of built binaries; stale job configs after the build output directory was renamed (e.g. artifacts/ -> dist/); running from a working directory where the relative path does not resolve.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/624e8b830978af16. Report an issue: GitHub.