debug
Browse files- app/main.py +9 -14
app/main.py
CHANGED
@@ -204,28 +204,23 @@ def init_vertex_ai():
|
|
204 |
print(f"First few characters: {safe_sample}")
|
205 |
raise
|
206 |
|
207 |
-
# Create credentials from the parsed JSON
|
208 |
try:
|
209 |
-
#
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
else:
|
216 |
-
print("No literal '\\n' found in private_key, using as is.")
|
217 |
|
218 |
credentials = service_account.Credentials.from_service_account_info(
|
219 |
-
credentials_info,
|
220 |
scopes=['https://www.googleapis.com/auth/cloud-platform']
|
221 |
)
|
222 |
project_id = credentials.project_id
|
223 |
print(f"Successfully created credentials object for project: {project_id}")
|
224 |
except Exception as cred_err:
|
225 |
-
print(f"ERROR: Failed to create credentials from
|
226 |
-
# Print the type of the private key for debugging
|
227 |
-
pk_type = type(credentials_info.get("private_key")).__name__ if "private_key" in credentials_info else "Not Found"
|
228 |
-
print(f"Private key type: {pk_type}")
|
229 |
raise
|
230 |
|
231 |
# Initialize the client with the credentials
|
|
|
204 |
print(f"First few characters: {safe_sample}")
|
205 |
raise
|
206 |
|
207 |
+
# Create credentials from the parsed JSON info (json.loads should handle \n)
|
208 |
try:
|
209 |
+
# DEBUG: Log snippet of private key before passing to library
|
210 |
+
pk_value = credentials_info.get("private_key", "KEY_NOT_FOUND")
|
211 |
+
if pk_value != "KEY_NOT_FOUND":
|
212 |
+
print(f"DEBUG: Snippet of private_key passed to from_service_account_info:\n{pk_value[:30]}...\n...{pk_value[-30:]}")
|
213 |
+
else:
|
214 |
+
print("DEBUG: private_key not found in credentials_info dict.")
|
|
|
|
|
215 |
|
216 |
credentials = service_account.Credentials.from_service_account_info(
|
217 |
+
credentials_info, # Pass the dictionary directly
|
218 |
scopes=['https://www.googleapis.com/auth/cloud-platform']
|
219 |
)
|
220 |
project_id = credentials.project_id
|
221 |
print(f"Successfully created credentials object for project: {project_id}")
|
222 |
except Exception as cred_err:
|
223 |
+
print(f"ERROR: Failed to create credentials from service account info: {cred_err}")
|
|
|
|
|
|
|
224 |
raise
|
225 |
|
226 |
# Initialize the client with the credentials
|