Closed
Description
In which file did you encounter the issue?
Did you change the file? If so, how?
No
Describe the issue
When copying an environment, the script fails with the following stack trace:
Composer operation successful.
Starting database transfer.
Obtaining service account `REDACTED` credentials to access SQL database.
Traceback (most recent call last):
File "copy_environment.py", line 732, in <module>
"diskSizeGb": args.override_disk_size_gb,
File "copy_environment.py", line 711, in clone_environment
copy_database(project, existing_env, new_env, running_as_service_account)
File "copy_environment.py", line 598, in copy_database
iam_client, project, gke_service_account_name
File "copy_environment.py", line 298, in create_service_account_key
base64.b64decode(service_account_key.get("privateKeyData", ""))
File "/usr/lib/python3.5/ast.py", line 84, in literal_eval
return _convert(node_or_string)
File "/usr/lib/python3.5/ast.py", line 83, in _convert
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: b'{\n "type": "service_account",\n "project_id": "...", ....}'
Root cause is that in Python 3, base64.b64decode returns a byte string which gets passed to ast.literal_eval(), which expects a string.