Skip to content

Custom Auth Path Validation Fails Due to Incorrect Path Parsing #17

@Sarthak422004

Description

@Sarthak422004

Bug: Custom Auth Path Validation Fails Due to Incorrect Path Parsing

Description

When using custom authentication with a module path containing a class name (e.g., src.auth.custom_auth:SignedHeaderAuth), the path validation in graph_config.py fails because it checks if the entire path including the class name exists as a file.

Current Behavior

The current code in graph_config.py (around line 71) does:

if method == "custom" and path:
    if Path(path).exists():  # This fails for "module.path:ClassName"
        return {...}

When path = "src.auth.custom_auth:SignedHeaderAuth":

  • Path("src.auth.custom_auth:SignedHeaderAuth").exists() → always returns False
  • This causes ValueError: Unsupported auth method even when the module file exists

Expected Behavior

The path validation should:

  1. Extract the file path portion before the : separator (class name)
  2. Convert the module path (dots) to filesystem path (slashes)
  3. Check if that converted path exists

Proposed Fix

if method == "custom" and path:
    # Extract file path before the ':' for existence check
    file_path = path.split(":")[0] if ":" in path else path
    # Convert module path (dots) to file path (slashes) and add .py
    if "." in file_path and "/" not in file_path:
        file_path = file_path.replace(".", "/") + ".py"
    
    if Path(file_path).exists():
        return {
            "method": "custom",
            "path": path,
        }

File Location

agentflow_cli/src/app/core/config/graph_config.py - auth_config() method

Example Configuration

{
  "auth": {
    "method": "custom",
    "path": "src.auth.custom_auth:SignedHeaderAuth"
  }
}

Impact

  • Severity: High
  • Affected Users: Anyone using custom authentication with module:class path format
  • Workaround: Manually patch the library file locally

Environment

  • Python 3.13
  • agentflow_cli (latest version)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions