Skip to content

⬆️ Use fetch instead of axios (second attempt)#1069

Merged
rdubigny merged 1 commit into
mainfrom
use-fetch-in-hybridge-rie-second-attempt
May 29, 2026
Merged

⬆️ Use fetch instead of axios (second attempt)#1069
rdubigny merged 1 commit into
mainfrom
use-fetch-in-hybridge-rie-second-attempt

Conversation

@rdubigny
Copy link
Copy Markdown
Contributor

@rdubigny rdubigny commented Apr 3, 2026

Problem

We want to remove axios to reduce the number of dependencies, which will also reduce the attack surface. We also want to standardize our practices by using fetch everywhere.

During the first attempt, we encountered an error in the production Internet environment with the IdP FIDGFiP-RIE.

Here are the details of the error:

"type": "OidcClientTokenFailedException",
"method": "GET",
"path": "/api/v2/oidc-callback",
"idpLabel": "Agents de la DGFiP (Réseau Interministériel de l'État)",
"code": "Y020026",
"causes": [
  {
    "type": "ClientError",
    "message": "parsing error occured",
    "stack": [
      "ClientError: parsing error occured",
      "    at e (file:///var/www/app/node_modules/openid-client/build/index.js:116:12)",
      "    at errorHandler (file:///var/www/app/node_modules/openid-client/build/index.js:137:23)",
      "    at authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:991:9)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
      "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
      "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
    ]
  },
  {
    "message": "failed to parse \"response\" body as JSON",
    "stack": [
      "OperationProcessingError: failed to parse \"response\" body as JSON",
      "    at OPE (file:///var/www/app/node_modules/oauth4webapi/build/index.js:116:12)",
      "    at getResponseJsonBody (file:///var/www/app/node_modules/oauth4webapi/build/index.js:2496:15)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
      "    at async processGenericAccessTokenResponse (file:///var/www/app/node_modules/oauth4webapi/build/index.js:1216:18)",
      "    at async processAuthorizationCodeOpenIDResponse (file:///var/www/app/node_modules/oauth4webapi/build/index.js:1417:20)",
      "    at async authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:980:18)",
      "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
      "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
    ],
    "type": "OperationProcessingError"
  },
  {
    "message": "terminated",
    "stack": [
      "TypeError: terminated",
      "    at Fetch.onAborted (node:internal/deps/undici/undici:12707:53)",
      "    at Fetch.emit (node:events:508:28)",
      "    at Fetch.terminate (node:internal/deps/undici/undici:11866:14)",
      "    at Object.onError (node:internal/deps/undici/undici:12831:38)",
      "    at Gunzip.emit (node:events:520:35)",
      "    at emitErrorNT (node:internal/streams/destroy:170:8)",
      "    at emitErrorCloseNT (node:internal/streams/destroy:129:3)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:89:21)"
    ],
    "type": "TypeError"
  },
  {
    "message": "incorrect header check",
    "stack": [
      "Error: incorrect header check",
      "    at genericNodeError (node:internal/errors:985:15)",
      "    at wrappedFn (node:internal/errors:539:14)",
      "    at Zlib.zlibOnError [as onerror] (node:zlib:190:17)"
    ],
    "type": "Error"
  }
],
"message": "parsing error occured",
"idpLoginHintFqdn": "dgfip.finances.gouv.fr",
"levelNumber": 50,
"originalError": {
  "name": "ClientError",
  "code": "OAUTH_PARSE_ERROR"
},
"statusCode": 400,
"idpName": "FIDGFiP-RIE",
"stackTrace": [
  "ClientError: parsing error occured",
  "    at e (file:///var/www/app/node_modules/openid-client/build/index.js:116:12)",
  "    at errorHandler (file:///var/www/app/node_modules/openid-client/build/index.js:137:23)",
  "    at authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:991:9)",
  "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
  "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
  "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)",
  "Error: parsing error occured",
  "    at OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8313:19)",
  "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
  "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
],
"level": "error",
"id": "a47bab91-5c43-47ab-a620-f44b867287cc",

Proposal

Replace axios with fetch.

Deploy the hyyyperbridge consumer to the production environment on nubo01,
without merging it to main, to observe how it behaves with the FIDGFiP-RIE
IdP.

@rdubigny
Copy link
Copy Markdown
Contributor Author

rdubigny commented Apr 3, 2026

@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch from 45640a7 to a4e953e Compare April 4, 2026 12:26
@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch 2 times, most recently from 39a5a9f to 8d8f057 Compare May 13, 2026 15:11
@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch from 8d8f057 to 55bf731 Compare May 13, 2026 15:16
@rdubigny
Copy link
Copy Markdown
Contributor Author

Note:

Issue nodejs/undici#4774 has been fixed by nodejs/undici#4775 and landed in Undici 7.24.6. This version will land in Node.js v24.16 via nodejs/node#63263 around mid-May.

@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch 3 times, most recently from 8a13db0 to 83016ee Compare May 28, 2026 15:01
@rdubigny rdubigny marked this pull request as ready for review May 28, 2026 15:38
@rdubigny rdubigny marked this pull request as draft May 28, 2026 15:40
Copy link
Copy Markdown
Contributor

@douglasduteil douglasduteil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch from 83016ee to 9c12441 Compare May 29, 2026 12:05
**Problem**

We want to remove `axios` to reduce the number of dependencies, which
will also reduce the attack surface.  We also want to standardize our
practices by using `fetch` everywhere.

During the first attempt, we encountered an error in the production
Internet environment with the IdP `FIDGFiP-RIE`.

Here are the details of the error:

```
"type": "OidcClientTokenFailedException",
"method": "GET",
"path": "/api/v2/oidc-callback",
"idpLabel": "Agents de la DGFiP (Réseau Interministériel de l'État)",
"code": "Y020026",
"causes": [
  {
    "type": "ClientError",
    "message": "parsing error occured",
    "stack": [
      "ClientError: parsing error occured",
      "    at e (file:///var/www/app/node_modules/openid-client/build/index.js:116:12)",
      "    at errorHandler (file:///var/www/app/node_modules/openid-client/build/index.js:137:23)",
      "    at authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:991:9)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
      "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
      "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
    ]
  },
  {
    "message": "failed to parse \"response\" body as JSON",
    "stack": [
      "OperationProcessingError: failed to parse \"response\" body as JSON",
      "    at OPE (file:///var/www/app/node_modules/oauth4webapi/build/index.js:116:12)",
      "    at getResponseJsonBody (file:///var/www/app/node_modules/oauth4webapi/build/index.js:2496:15)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
      "    at async processGenericAccessTokenResponse (file:///var/www/app/node_modules/oauth4webapi/build/index.js:1216:18)",
      "    at async processAuthorizationCodeOpenIDResponse (file:///var/www/app/node_modules/oauth4webapi/build/index.js:1417:20)",
      "    at async authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:980:18)",
      "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
      "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
    ],
    "type": "OperationProcessingError"
  },
  {
    "message": "terminated",
    "stack": [
      "TypeError: terminated",
      "    at Fetch.onAborted (node:internal/deps/undici/undici:12707:53)",
      "    at Fetch.emit (node:events:508:28)",
      "    at Fetch.terminate (node:internal/deps/undici/undici:11866:14)",
      "    at Object.onError (node:internal/deps/undici/undici:12831:38)",
      "    at Gunzip.emit (node:events:520:35)",
      "    at emitErrorNT (node:internal/streams/destroy:170:8)",
      "    at emitErrorCloseNT (node:internal/streams/destroy:129:3)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:89:21)"
    ],
    "type": "TypeError"
  },
  {
    "message": "incorrect header check",
    "stack": [
      "Error: incorrect header check",
      "    at genericNodeError (node:internal/errors:985:15)",
      "    at wrappedFn (node:internal/errors:539:14)",
      "    at Zlib.zlibOnError [as onerror] (node:zlib:190:17)"
    ],
    "type": "Error"
  }
],
"message": "parsing error occured",
"idpLoginHintFqdn": "dgfip.finances.gouv.fr",
"levelNumber": 50,
"originalError": {
  "name": "ClientError",
  "code": "OAUTH_PARSE_ERROR"
},
"statusCode": 400,
"idpName": "FIDGFiP-RIE",
"stackTrace": [
  "ClientError: parsing error occured",
  "    at e (file:///var/www/app/node_modules/openid-client/build/index.js:116:12)",
  "    at errorHandler (file:///var/www/app/node_modules/openid-client/build/index.js:137:23)",
  "    at authorizationCodeGrant (file:///var/www/app/node_modules/openid-client/build/index.js:991:9)",
  "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
  "    at async OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8291:22)",
  "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)",
  "Error: parsing error occured",
  "    at OidcClientService.getToken (/var/www/app/dist/instances/app/main.js:8313:19)",
  "    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)",
  "    at async OidcClientController.getOidcCallback (/var/www/app/dist/instances/app/main.js:14396:50)"
],
"level": "error",
"id": "a47bab91-5c43-47ab-a620-f44b867287cc",
```

**Proposal**

Replace `axios` with `fetch`.

**TODO**

Investigate and fix the issue with the `FIDGFiP-RIE` IdP.
@rdubigny rdubigny force-pushed the use-fetch-in-hybridge-rie-second-attempt branch from 9c12441 to 790d7c9 Compare May 29, 2026 12:41
@rdubigny
Copy link
Copy Markdown
Contributor Author

We deployed this PR for one hour and did not see any specific error with the FIDGFiP-RIE IdP.

@rdubigny rdubigny marked this pull request as ready for review May 29, 2026 14:09
@rdubigny rdubigny merged commit a28e580 into main May 29, 2026
42 checks passed
@rdubigny rdubigny deleted the use-fetch-in-hybridge-rie-second-attempt branch May 29, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants