Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

chore: display error message from response when tool repository login fails (#4075)

Heitor Carvalho0632a054cad2
diff --git a/lib/crewai/src/crewai/cli/tools/main.py b/lib/crewai/src/crewai/cli/tools/main.py
index 13fd257fe..8fe803980 100644
--- a/lib/crewai/src/crewai/cli/tools/main.py
+++ b/lib/crewai/src/crewai/cli/tools/main.py
@@ -1,4 +1,5 @@
import base64
+from json import JSONDecodeError
import os
from pathlib import Path
import subprocess
@@ -162,9 +163,19 @@ class ToolCommand(BaseCommand, PlusAPIMixin):
if login_response.status_code != 200:
console.print(
- "Authentication failed. Verify if the currently active organization access to the tool repository, and run 'crewai login' again. ",
+ "Authentication failed. Verify if the currently active organization can access the tool repository, and run 'crewai login' again.",
style="bold red",
)
+ try:
+ console.print(
+ f"[{login_response.status_code} error - {login_response.json().get('message', 'Unknown error')}]",
+ style="bold red italic",
+ )
+ except JSONDecodeError:
+ console.print(
+ f"[{login_response.status_code} error - Unknown error - Invalid JSON response]",
+ style="bold red italic",
+ )
raise SystemExit
login_response_json = login_response.json()