bug fix
Browse files- app/main.py +13 -1
app/main.py
CHANGED
@@ -206,6 +206,15 @@ def init_vertex_ai():
|
|
206 |
|
207 |
# Create credentials from the parsed JSON
|
208 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
credentials = service_account.Credentials.from_service_account_info(
|
210 |
credentials_info,
|
211 |
scopes=['https://www.googleapis.com/auth/cloud-platform']
|
@@ -213,7 +222,10 @@ def init_vertex_ai():
|
|
213 |
project_id = credentials.project_id
|
214 |
print(f"Successfully created credentials object for project: {project_id}")
|
215 |
except Exception as cred_err:
|
216 |
-
print(f"ERROR: Failed to create credentials from parsed JSON: {cred_err}")
|
|
|
|
|
|
|
217 |
raise
|
218 |
|
219 |
# Initialize the client with the credentials
|
|
|
206 |
|
207 |
# Create credentials from the parsed JSON
|
208 |
try:
|
209 |
+
# Explicitly replace literal "\\n" with actual newline in private_key
|
210 |
+
if "private_key" in credentials_info and isinstance(credentials_info["private_key"], str):
|
211 |
+
original_pk = credentials_info["private_key"]
|
212 |
+
credentials_info["private_key"] = original_pk.replace("\\n", "\n")
|
213 |
+
if original_pk != credentials_info["private_key"]:
|
214 |
+
print("Replaced literal '\\n' with newline characters in private_key.")
|
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']
|
|
|
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 parsed JSON (after potential newline replacement): {cred_err}")
|
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
|