Closed Bug 1691805 Opened 8 months ago Closed 8 months ago

Lots of "400 Client Error" reported for Google API in the logs.

Categories

(Webtools Graveyard :: Pontoon, defect, P1)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: flod, Assigned: mathjazz)

Details

Attachments

(1 file)

From the URL recorded in Papertrail, it looks like we're sending out requests with an empty target locale, e.g. Google Translate error: 400 Client Error: Bad Request for url: https://translation.googleapis.com/language/translate/v2?q=Want+to+make+a+difference%3F+Fix+a+bug+that+fits+your+interests.&source=en&target=&format=text&key=APIKEY

Wild guess: we're still sending a request when the Google translate code: field is empty for the locale, and we clearly shouldn't send any.

The following check doesn't work as expected if the locale_code is "".

# Validate if locale exists in the database to avoid any potential XSS attacks.
if not Locale.objects.filter(google_translate_code=locale_code).exists():
    return JsonResponse(
        {
            "status": False,
            "message": "Not Found: {error}".format(error=locale_code),
        },
        status=404,
    )
Priority: -- → P1
Assignee: nobody → m
Status: NEW → ASSIGNED
Attached file GitHub Pull Request
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.