Skip to content

Add detailed error logging for client credentials authentication #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/uipath/_cli/_auth/_client_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,20 @@ def authenticate(
"refresh_token": "",
"id_token": "",
}

case 400:
try:
error_details = response.json()
console.info(f"DEBUG: Error details: {error_details}")
except Exception:
console.info(f"DEBUG: Raw error response: {response.text}")

console.error(
"Invalid client credentials or request parameters."
)

return None

case 401:
console.error("Unauthorized: Invalid client credentials.")
return None
Expand Down
12 changes: 9 additions & 3 deletions src/uipath/_cli/cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ def python_run_middleware(
try:

async def execute():
context = UiPathRuntimeContext.from_config(
env.get("UIPATH_CONFIG_PATH", "uipath.json")
)
config_path = env.get("UIPATH_CONFIG_PATH", "uipath.json")
console.info(f"[DEBUG] Using config path: {config_path}")
console.info(f"[DEBUG] Entrypoint argument: {entrypoint}")
console.info(f"[DEBUG] Entrypoint absolute path: {os.path.abspath(entrypoint) if entrypoint else None}")
console.info(f"[DEBUG] Entrypoint exists: {os.path.exists(entrypoint) if entrypoint else None}")
console.info(f"[DEBUG] Input: {input}")
context = UiPathRuntimeContext.from_config(config_path)
context.entrypoint = entrypoint
context.input = input
context.resume = resume
Expand Down Expand Up @@ -93,13 +97,15 @@ async def execute():
return MiddlewareResult(should_continue=False)

except UiPathRuntimeError as e:
console.info(f"[DEBUG][UiPathRuntimeError] {type(e).__name__}: {e}")
return MiddlewareResult(
should_continue=False,
error_message=f"Error: {e.error_info.title} - {e.error_info.detail}",
should_include_stacktrace=False,
)
except Exception as e:
# Handle unexpected errors
console.info(f"[DEBUG][Exception] {type(e).__name__}: {e}")
return MiddlewareResult(
should_continue=False,
error_message=f"Error: Unexpected error occurred - {str(e)}",
Expand Down
Loading