BatchRequestContent breaks on Node20+

Aperta
#1,998 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
node.js, typescript

Direzione di ricerca

Start with BatchRequestContent and reproduce the relative-URL case on Node 20 using the example in the issue. Trace how request URLs are constructed, including client.api(relativeUrl)'buildFullUrl' and the reported double-host behavior. Done means the documented batch-request pattern works with relative URLs without prepending the API host twice.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status:waiting-for-triage type:bug
Describe the bug

While using older Node versions without undici fetch, we used the BatchRequestContent class of the Graph SDK to create batch requests. This operates on standard Request objects, but appears to use them mostly as URL containers, not actually sending those requests, because relative URLs are supported:

new BatchRequestContent([
  {id: "1", request: new Request("/users/foo@domain.com")}, 
  {id: "2", request: new Request("/users/bar@domain.com")}
]);

Since upgrading to Node 20 (way overdue, I know!), this pattern breaks, because the Request constructor does not support relative URLs:

TypeError: Failed to parse URL from users/foo@domain.com
    at new Request (node:internal/deps/undici/undici:9580:19)

How is the BatchRequestContent class intended to be used on Node 20+? Couldn't the SDK define a BatchRequestContainer class that implements Request while merely functioning as an URL container, supporting the previous pattern of relative URLs? Or perhaps a static BatchRequestStep helper?

Or should clients have to manually extract the base URL of the API and prepend it to all batch request steps? What is the preferred way of doing so?
Rather than hard-coding it, I realized I could do client.api(relativeUrl)['buildFullUrl']() but this relies on a private method.

Edit: I realized that even if i DO supply a full URL, I will instead get an error Resource not found for the segment 'v1.0, supposedly because the API host will be prepended twice.

Expected behavior

BatchRequestContent should work with relative URLs on Node 20+

How to reproduce

Create a batch request content and pass one or more relative URLs like /users/foo

SDK Version

3.0.7

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
Lingua principale
TypeScript
Stelle
833
Fork
240
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoftgraph/msgraph-sdk-javascript

Tutte le issue di microsoftgraph/msgraph-sdk-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.