googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.2k stars 3.52k forks source link

Intermittent Exception / Precondition check failed #2558

Closed billynoah closed 1 month ago

billynoah commented 5 months ago

Environment details

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?

VladislavOkishev commented 4 months ago

I have the same problem(

mrsateeshp commented 3 months ago

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

lykalabrada commented 2 months ago

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

Hectorhammett commented 1 month ago

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.