{"record":{"id":"624e8b830978af16","repo":"cloudflare/cloudflared","slug":"the-argument-path-must-be-a-directory","errorCode":null,"errorMessage":"the argument path must be a directory","messagePattern":"the argument path must be a directory","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"github_release.py","lineNumber":309,"sourceCode":"                logging.error(\"dryrun failed\")\n            return\n        else:\n            client = Github(args.api_key)\n            repo = client.get_repo(CLOUDFLARED_REPO)\n\n            if os.path.isdir(args.path):\n                onlyfiles = [f for f in listdir(args.path) if isfile(join(args.path, f))]\n                for filename in onlyfiles:\n                    binary_path = os.path.join(args.path, filename)\n                    assert_asset_version(binary_path, args.release_version)\n                release = get_or_create_release(repo, args.release_version, args.dry_run, args.draft)\n                for filename in onlyfiles:\n                    binary_path = os.path.join(args.path, filename)\n                    upload_asset(release, binary_path, filename, args.release_version, args.kv_account_id, args.namespace_id,\n                    args.kv_api_token)\n                    move_asset(binary_path, filename)\n            else:\n                raise Exception(\"the argument path must be a directory\")\n\n    except Exception as e:\n        logging.exception(e)\n        exit(1)\n\nmain()\n","sourceCodeStart":291,"sourceCodeEnd":316,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/github_release.py#L291-L316","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the path exists and is a directory before invoking the script: test -d \"$PATH\" || exit 1.","Pass the correct directory containing the built binaries via --path.","Fix the CI working directory or build step so the artifact directory is present at the given path.","Add an explicit pre-check in main (os.path.isdir) for a clearer error message including the actual path."],"exampleFix":"// before\nraise Exception(\"the argument path must be a directory\")\n// after\nraise Exception(f\"the argument path must be a directory: {args.path!r}\")","handlingStrategy":"validation","validationCode":"import argparse, os\np = argparse.ArgumentParser()\np.add_argument(\"--path\", required=True)\nargs = p.parse_args()\nif not os.path.isdir(args.path):\n    p.error(f\"--path must be an existing directory: {args.path}\")","typeGuard":null,"tryCatchPattern":"try:\n    main()\nexcept SystemExit as e:\n    if e.code != 0:\n        logging.error(\"release failed, see logs above\")","preventionTips":["Run test -d \"$ARTIFACT_DIR\" as a pre-step in CI","Keep the build output directory name stable and reference it via an env var","Pass absolute paths to avoid working-directory surprises"],"tags":["cli","filesystem","path","python"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}