client.api() throws "Unable to parse the URL" for relative paths containing https:// in the query
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 85/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, node.js, typescript
- Bereich
- api
Rechercherichtung
Beginne bei parsePath in src/GraphRequest.ts um Zeile 134, wo die Prüfung auf absolute URLs path.indexOf("https://") verwendet, bevor new URL(path) aufgerufen wird; führe das Repro-Skript aus dem Issue gegen einen lokalen Build aus, um die drei Fehler zu sehen. Ändere den Test auf eine startsWith-Prüfung, die Groß-/Kleinschreibung ignoriert, sodass nur echte absolute Pfade diesen Zweig nehmen, und lass den relativen Zweig weiterhin gegen die konfigurierte Basis-URL plus Version auflösen. Fertig sieht so aus, dass alle drei Repro-Pfade die erwarteten https://graph.microsoft.com/v1.0/... URLs ausgeben, während vollständige https://graph.microsoft.com/... Pfade weiterhin geparst werden, plus ein Regressionstest in der bestehenden GraphRequest-Suite.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
client.api(path) throws Error: Unable to parse the URL: ... (GraphClientError) when given a relative path whose query string or OData function parameter contains https://, such as /sites?search=https://contoso.sharepoint.com or /me/events?$filter=onlineMeeting/joinUrl eq 'https://...'.
In 3.0.7, the same calls did not throw, but stripped https:// from the query and built a broken URL (https:/v1.0/sites?search=contoso.sharepoint.com).
Expected behavior
Relative paths should resolve against the configured base URL and version (https://graph.microsoft.com/v1.0/sites?search=https://contoso.sharepoint.com, etc.), matching the behavior of .query() and .filter() for the same values.
How to reproduce
npm install @microsoft/[email protected]
node repro.js
repro.js:
const { Client } = require("@microsoft/microsoft-graph-client");
const client = Client.init({ authProvider: (done) => done(null, "token") });
for (const path of [
"/sites?search=https://contoso.sharepoint.com",
"/me/events?$filter=onlineMeeting/joinUrl eq 'https://teams.microsoft.com/l/x'",
"/me/drive/root/search(q='https://example')",
]) {
try {
console.log(client.api(path).buildFullUrl());
} catch (e) {
console.log(e.message);
}
}
Actual output (3.1.0):
Unable to parse the URL: /sites?search=https://contoso.sharepoint.com
Unable to parse the URL: /me/events?$filter=onlineMeeting/joinUrl eq 'https://teams.microsoft.com/l/x'
Unable to parse the URL: /me/drive/root/search(q='https://example')
SDK Version
3.1.0 (also on dev 4434ef722 and main ba4103712)
Latest version known to work for scenario above?
None (3.0.7 returned malformed URLs such as https:/v1.0/sites?search=contoso.sharepoint.com instead of throwing)
Known Workarounds
Pass the parameter through .query() / .filter() instead of inline in api(), or percent-encode :// in the parameter value.
Debug output
Click to expand log
Error: Unable to parse the URL: /sites?search=https://contoso.sharepoint.com
at new GraphClientError (node_modules/@microsoft/microsoft-graph-client/lib/src/GraphClientError.js:30:28)
at GraphRequest.parsePath (node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:51:27)
at new GraphRequest (node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:105:14)
at Client.api (node_modules/@microsoft/microsoft-graph-client/lib/src/Client.js:97:16)
Configuration
- OS: Linux x64
- Node.js: v26.13.0 (not OS- or runtime-specific)
Other information
GraphRequest.parsePath (src/GraphRequest.ts, line 134) checks if (path.indexOf("https://") !== -1) to decide whether path is an absolute URL, and PR #2000 added new URL(path) inside that branch. Checking whether path starts with https:// (case-insensitively) instead of indexOf would avoid treating query values containing https:// as absolute URLs.
Credit: https://ucsbplse.github.io/
- Vorherrschende Sprache
- TypeScript
- Sterne
- 836
- Forks
- 241
- Ø Merge
- 1 T. 12 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoftgraph/msgraph-sdk-javascript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoftgraph/msgraph-sdk-javascript#2011 ·
Maintainer antworten meist innerhalb von 1 Tag
-
status:waiting-for-triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
microsoftgraph/msgraph-sdk-javascript#1956 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Is anyone here?Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Is it really correct that the Javascript version of the graph SDK doesn't offer typed requests?Offenstatus:waiting-for-triage
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 42/100
microsoftgraph/msgraph-sdk-javascript#2004 ·
Maintainer antworten meist innerhalb von 1 Tag
-
status:waiting-for-triage type:bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoftgraph/msgraph-sdk-javascript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
fb55/htmlparser2#2579 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue needs-review
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 83/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add Module DB RulesOffendocumentation public
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 68/100
midnightntwrk/umbradb#65 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
area/channels kind/bug priority/medium
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nanocoai/nanoclaw#4501 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs verification
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 13 Tagen