google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

Intermittent Exception / Precondition check failed

Open billynoah opened this issue 1 year ago • 3 comments

Environment details

  • OS: Ubuntu 22.04
  • PHP version: 7.4.3
  • Package name and version: Google_Service_Gmail

Steps to reproduce

We are experiencing intermittent issue where listing gmail messages returns a Google Service Exception:

PHP Fatal error:  Uncaught Google\Service\Exception: {
  "error": {
    "code": 400,
    "message": "Precondition check failed.",
    "errors": [
      {
        "message": "Precondition check failed.",
        "domain": "global",
        "reason": "failedPrecondition"
      }
    ],
    "status": "FAILED_PRECONDITION"
  }
}

Code example

$this->service->users_messages->listUsersMessages('me', $params);

This happens in a job that runs approx once every 60 seconds. Every time it runs the token is refreshed so presumably it is not an authentication issue. In the course of a day it might happen 1% - 2% of of the time out of 1000 times the job runs. So not very often, but often enough that it is cause for concern.

This has been going on for years. Is there anything we can do or is it simply a glitch in the API server where we should just wait and make the request later?

billynoah avatar Feb 01 '24 20:02 billynoah

I have the same problem(

VladislavOkishev avatar Mar 06 '24 14:03 VladislavOkishev

we observe the same issue every day. same use case.

mrsateeshp avatar Apr 03 '24 21:04 mrsateeshp

We've just come across this same problem, we are using NodeJS and trying to send an email on behalf of a user. It is also intermittent. Looks like it's an issue on the googleapis core

[Update] in our case, this is only happening for specific users

lykalabrada avatar Apr 15 '24 16:04 lykalabrada

Hello!

Thanks so much for reaching out, this definitely seems an issue with the API more than the library.

Here is some information I found looking around related to the issue, I hope it helps! https://stackoverflow.com/questions/77300161/getting-precondition-check-failed-when-using-gmail-api-with-a-service-account

Closing the issue as it is not related to the library.

Hectorhammett avatar May 31 '24 22:05 Hectorhammett