dataform icon indicating copy to clipboard operation
dataform copied to clipboard

Dataform CLI Error: request to https://oauth2.googleapis.com/token failed

Open BenJackGill opened this issue 2 months ago • 4 comments

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]

BenJackGill avatar Nov 04 '25 07:11 BenJackGill

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.

BenJackGill avatar Nov 04 '25 08:11 BenJackGill

How frequently do you see this error? It may be a transient issue to call this API to generate tokens

kolina avatar Nov 05 '25 20:11 kolina

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.

BenJackGill avatar Nov 06 '25 10:11 BenJackGill

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

kolina avatar Nov 07 '25 00:11 kolina