Dataform CLI Error: request to https://oauth2.googleapis.com/token failed
The Dataform CLI is throwing errors like this:
Dataform encountered an error: request to https://oauth2.googleapis.com/token failed, reason:
FetchError: request to https://oauth2.googleapis.com/token failed, reason:
at ClientRequest.<anonymous> (/Users/BenJackGill/.nvm/versions/node/v22.17.0/lib/node_modules/@dataform/cli/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:518:28)
at emitErrorEvent (node:_http_client:104:11)
at TLSSocket.socketErrorListener (node:_http_client:518:5)
at TLSSocket.emit (node:events:518:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:90:21)
at runNextTicks (node:internal/process/task_queues:69:3)
at listOnTimeout (node:internal/timers:549:9)
Each time I do gcloud auth application-default login and it works for one or two more commands before showing the same error again.
I am using the latest @dataform/[email protected]
Just noticed that when I see this error I can ignore it sometimes and re-run the same command (i.e. dataform run) and it works.
So the error is a false positive. Something else is wrong here.
How frequently do you see this error? It may be a transient issue to call this API to generate tokens
It happens daily. Some days worse than others but it's always showing up.
Noting that other Google product CLI's (firebase, etc) don't have this problem. The ADC is always respected.
We don't do anything special except for the fact that the CLI needs to make a lot of calls to the BigQuery API to poll jobs status.
One way for a fix is to customize retry predicate of the BQ client for this specific error: we construct this client here
You can send this PR if you feel doing it