Hello,
I am experiencing an issue with the Google Cloud Translation API when trying to delete glossaries programmatically. Specifically, when I use the delete_glossary function to delete an existing glossary, I receive an InvalidArgument error, and the glossary is not deleted.
Issue Details:
I am using the following code to delete a glossary:
from google.cloud import translate_v3beta1 as translate from google.api_core.exceptions import DeadlineExceeded from google.oauth2.service_account import Credentials def delete_glossary( source_lang, target_lang, timeout: int = 180,): credentials = Credentials.from_service_account_file('service_account.json') client = translate.TranslationServiceClient(credentials=credentials) GLOSSARY_PREFIX = "GLOSSARY_PREFIX" # Replaced with actual prefix PROJECT_ID = "PROJECT_ID" # Replaced with actual project ID glossary_id = f"{GLOSSARY_PREFIX}_{source_lang}_{target_lang}" name = client.glossary_path(PROJECT_ID, "us-central1", glossary_id) try: operation = client.delete_glossary(name=name) result = operation.result(timeout) print(f"Deleted Success: {result.name}") except DeadlineExceeded: print(f"Deadline Exceeded. Retry Deleting Glossary: {glossary_id}") delete_glossary(source_lang, target_lang) except Exception as e: print(f"Deleted Error: {name}") print(f"Error details: {e}")
I receive the following error:
Deleted Error: projects/PROJECT_ID/locations/us-central1/glossaries/GLOSSARY_PREFIX_ko_xh
400 Request contains an invalid argument.
<class 'google.api_core.exceptions.InvalidArgument'>
To verify that the glossary exists, I used the following code to list glossaries.
The output confirms that the glossary exists:
Name: projects/PROJECT_ID/locations/us-central1/glossaries/GLOSSARY_PREFIX_ko_xh
Troubleshooting Steps Taken:
Despite these steps, the InvalidArgument error persists, and I am unable to delete the glossary programmatically.
Questions:
Any assistance or guidance on this matter would be greatly appreciated.
Thank you.
Hey @kwkang , I had exactly same issue by keep saying "Request contains an invalid argument"
This was actually, google cloud permission issue and they recently releases new update here Oct 4
Solution: you should try from same region with your project root region. In your case "us-central1"
in addition.
we have multiple regions in our system and google project root is in us-central1 region.
So, we were trying to create a glossary from region [kr server]. So, I switched to US region and it worked.
Hello everyone,
I wanted to provide an update regarding the issue I was experiencing. I tried again over the past weekend, and the problem has disappeared. The delete_glossary function is now working as expected, and I am able to delete glossaries without any errors.
Thank you all for your assistance and suggestions. Your help was greatly appreciated.
Best regards,
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |