CoplayDev/unity-mcp · error · RuntimeError

--remote-url must be a non-empty URL

Error message

--remote-url must be a non-empty URL

What it means

Raised by main() in prepare_unity_asset_store_release.py when --remote-url, after stripping whitespace, is empty. argparse declares the flag as required=True, which rejects a missing flag entirely — but argparse still accepts an empty or whitespace-only string as a valid value. This secondary check catches that gap and aborts before the URL is injected into C# source.

Source

Thrown at tools/prepare_unity_asset_store_release.py:106

    )
    parser.add_argument(
        "--backup",
        action="store_true",
        help="Backup existing Assets/MCPForUnity before replacing.",
    )
    parser.add_argument(
        "--dry-run",
        action="store_true",
        help="Only validate that operations would succeed; do not write/copy/delete.",
    )
    args = parser.parse_args()

    repo_root = Path(args.repo_root).expanduser().resolve()
    asset_project = Path(args.asset_project).expanduser().resolve(
    ) if args.asset_project else (repo_root / "TestProjects" / "AssetStoreUploads")
    remote_url = args.remote_url.strip()
    if not remote_url:
        raise RuntimeError("--remote-url must be a non-empty URL")

    source_mcp = repo_root / "MCPForUnity"
    if not source_mcp.is_dir():
        raise RuntimeError(
            f"Source MCPForUnity folder not found: {source_mcp}")

    assets_dir = asset_project / "Assets"
    if not assets_dir.is_dir():
        raise RuntimeError(f"Assets folder not found: {assets_dir}")

    dest_mcp = assets_dir / "MCPForUnity"

    if args.dry_run:
        print("[dry-run] Validated paths. No changes applied.")
        print("[dry-run] Would stage a temporary copy of MCPForUnity and apply Asset Store edits there.")
        print(
            f"[dry-run] Would replace:\n- {dest_mcp}\n  with\n- {source_mcp}")
        return 0

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Provide a real non-empty URL: --remote-url https://your.remote.endpoint/
  2. If sourcing from an environment variable, ensure it is exported and non-empty before invoking the script, e.g. test -n "$REMOTE_URL" && python tools/prepare_unity_asset_store_release.py --remote-url "$REMOTE_URL".
  3. Add a URL-format validation (e.g. urllib.parse) if you want to catch malformed values earlier.

Example fix

# before
python tools/prepare_unity_asset_store_release.py --remote-url ""

# after
python tools/prepare_unity_asset_store_release.py --remote-url https://your.remote.endpoint/
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse

def is_valid_remote_url(url: str) -> bool:
    stripped = url.strip()
    if not stripped:
        return False
    parsed = urlparse(stripped)
    return parsed.scheme in ("http", "https") and bool(parsed.netloc)

# Before invoking the script:
if not is_valid_remote_url(my_url):
    raise SystemExit("REMOTE_URL must be a non-empty http(s) URL")

Prevention

When it happens

Trigger: Invoked with --remote-url "", --remote-url " ", or an env-var expansion that resolves to blank (e.g. --remote-url "$REMOTE_URL" when the variable is unset). The .strip() result is falsy, triggering the RuntimeError.

Common situations: CI pipeline where the remote URL is supplied via an environment variable that wasn't set; copy-paste of the example command without filling in the actual URL; shell quoting that passes an empty expansion.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/808b5e482f37dfce. Report an issue: GitHub.