Skip to content

[Bug] _is_known_path fails path validation for host-level UNC roots (e.g. \\<host> ) #1321

Description

@patrickjahns

Describe the bug

The _is_known_path helper function (introduced in #1294) by @crowecawcaw
fails to validate valid asset paths when deadline_known_asset_paths contains a UNC root configured at the host level (e.g., \\192.168.20.20), rather than including a share name (e.g., \\192.168.20.20\projects).

Root cause:

On Windows, os.path.commonpath([norm_root, norm_candidate]) internally invokes os.path.splitdrive():

os.path.splitdrive(r"\\192.168.20.20") treats \\192.168.20.20 as having an empty drive ("") because no share component is present.

os.path.splitdrive(r"\\192.168.20.20\projects\file.c4d") treats \\192.168.20.20\projects as the drive (r"\\192.168.20.20\projects").

Because commonpath detects two mismatched drives, it raises ValueError: Paths don't have the same drive. The except ValueError: block in _is_known_path catches this exception and returns False, causing valid asset paths under that server to fail validation.

This prevents us

Expected Behaviour

_is_known_path(candidate_path, known_roots) should evaluate to True when candidate_path is a child path residing under the host defined in known_roots.

Successful submission for files living on a Network Share in Windows with a \\<host> path

Current Behaviour

_is_known_path catches a ValueError during os.path.commonpath execution and returns False for all candidate paths under host-level UNC roots.

It prevents us from successfully submitting to deadline cloud

Reproduction Steps

Run the following script on Windows or using Python's ntpath:

import os
from pathlib import Path

def _is_known_path(path: Path | str, known_roots: list[Path | str]) -> bool:
    norm_candidate = os.path.normpath(str(path))
    for known_path in known_roots:
        norm_root = os.path.normpath(str(known_path))
        try:
            if os.path.commonpath([norm_root, norm_candidate]) == norm_root:
                return True
        except ValueError:
            continue
    return False

# Setup
known_roots = [r"\\192.168.20.20"]
candidate_path = r"\\192.168.20.20\projects\assets\FA_Anim\260304_FA_Anim.c4d"

# Reproduction
result = _is_known_path(candidate_path, known_roots)
print(f"Result: {result}")  # Prints False, expected True

Environment

  • Windows
  • Python 3.11
  • deadline-cloud==0.6.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions