Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate: BadRequest: "Too many text segments" #5425

Closed
randomcanary opened this issue May 31, 2018 · 7 comments
Closed

Translate: BadRequest: "Too many text segments" #5425

randomcanary opened this issue May 31, 2018 · 7 comments
Assignees
Labels
api: translation Issues related to the Cloud Translation API API. backend type: question Request for information or clarification. Not an issue.

Comments

@randomcanary
Copy link

randomcanary commented May 31, 2018

Code example:

from google.cloud import translate

def translate_phrases(text, target_lang='es'):
    global translate_client
    translation = translate_client.translate(
        text,
        target_language=target_lang)
    translated_texts = []
    for obj in translation:
        translated_texts.append(obj['translatedText'])
    return translated_texts    

Error obtained: BadRequest: 400 POST https://translation.googleapis.com/language/translate/v2: Too many text segments

Input: Python list of strings totaling up 819 characters.

@tseaver tseaver added type: question Request for information or clarification. Not an issue. api: translation Issues related to the Cloud Translation API API. labels Jun 1, 2018
@tseaver tseaver changed the title Translate: python3 client : BadRequest: 400 POST https://translation.googleapis.com/language/translate/v2: Too many text segments Translate: BadRequest: "Too many text segments" Jun 1, 2018
@tseaver tseaver added the backend label Jun 1, 2018
@tseaver
Copy link
Contributor

tseaver commented Jun 1, 2018

@randomcanary Thanks for the report. As far as I can see, the translate API quota docs don't show a per-request limit for number of charaters / segments. As a workaround, you could try breaking the list of segments up into smaller chunks.

@theacodes Who is our PoC for translate API backend issues?

@tseaver
Copy link
Contributor

tseaver commented Oct 18, 2018

/cc @beccasaurus

@ghost
Copy link

ghost commented Dec 28, 2018

what's the default quota for translation api.
when I use a long list in the translate_client.translate(origin, target_language=target_language)
methods it return

 raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 POST https://translation.googleapis.com/language/translate/v2: Too many text segments

try it yourself,Are U kidding me?

@warpdriv
Copy link

100 at a time works for me. HTH

@OpenSpacesAndPlaces
Copy link

I am seeing the same problem in C# too.

May be related to:
googleapis/google-cloud-dotnet#2957

The problem IMO is that the limits seem arbitrary and it makes for junky and/or inefficient end code.

@crwilcox crwilcox self-assigned this Dec 6, 2019
@crwilcox
Copy link
Contributor

crwilcox commented Dec 6, 2019

I did some investigating and you can send up to 128 segments. There are also limitations on the number of overall characters, but that is well documented on failure.

Request payload size exceeds the limit: 204800 bytes.

I have requested that the error for too many segments informs you of how many segments are allowed.

@crwilcox crwilcox closed this as completed Dec 6, 2019
@crwilcox
Copy link
Contributor

crwilcox commented Dec 6, 2019

For reference, internal issue b/145825761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: translation Issues related to the Cloud Translation API API. backend type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants