client.api() throws "Unable to parse the URL" for relative paths containing https:// in the query
维护者通常 1 天内回复
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 85/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js, typescript
- 领域
- api
调研方向
从 parsePath 开始,它位于 src/GraphRequest.ts 第 134 行附近,绝对 URL 检查使用 path.indexOf("https://"),然后才调用 new URL(path);针对本地构建运行 issue 中的复现脚本,以看到这三个失败。将测试改为不区分大小写的 startsWith 检查,使只有真正的绝对路径进入该分支,并保持相对分支根据配置的基础 URL 加版本进行解析。完成后的样子是:三个复现路径都打印出预期的 https://graph.microsoft.com/v1.0/... URL,而完整的 https://graph.microsoft.com/... 路径仍然可以解析,并且在现有的 GraphRequest 测试套件中有一个回归测试。
由索引模型根据 Issue 内容生成。
描述
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/
- 主要语言
- TypeScript
- 星标
- 836
- 派生
- 241
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-javascript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
microsoftgraph/msgraph-sdk-javascript#2011 ·
维护者通常 1 天内回复
-
status:waiting-for-triage
难度 1/5 1 小时以内 新手友好度 62/100
microsoftgraph/msgraph-sdk-javascript#1956 ·
维护者通常 1 天内回复
-
Is anyone here?未关闭
难度 4/5 3-5 天 新手友好度 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · 1 个 reaction ·
维护者通常 1 天内回复
-
status:waiting-for-triage
难度 5/5 一周以上 新手友好度 42/100
microsoftgraph/msgraph-sdk-javascript#2004 ·
维护者通常 1 天内回复
-
status:waiting-for-triage type:bug
难度 3/5 1-2 天 新手友好度 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 microsoftgraph/msgraph-sdk-javascript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复