bug(gapic-node-processing): setOnlyDefaultSystemTests incorrectly matches substring on absolute path
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
- 领域
- build-system, tooling
调研方向
从 gapic-node-processing/src/combine-libraries.ts 开始,检查 setOnlyDefaultSystemTests(),重点关注规范化绝对路径的匹配方式。复现或检查 issue 中描述的 v2/v3 fixture 情况,然后验证版本过滤不会受到 /tmp/upgrade-nodejs-v2Mp8W 等无关目录名称的影响,并且生成的 fixture 输出不再产生意外的 diff。
由索引模型根据 Issue 内容生成。
描述
Description
In gapic-node-processing/src/combine-libraries.ts, setOnlyDefaultSystemTests() filters out sample test fixtures from non-default versions when combining multi-version libraries (e.g., google-iam with v2 and v3).
It currently uses .includes(defaultVersion) on the full absolute file path:
function setOnlyDefaultSystemTests(defaultVersion: string, filePaths: FilePaths[]) {
const systemTestRegex = new RegExp('system-test/fixtures/sample/src');
for (let i = filePaths.length - 1; i >= 0; i--) {
const filePathObj = filePaths[i];
const normalizedPath = filePathObj.filePath.replace(/\\/g, '/');
if (systemTestRegex.test(normalizedPath) &&
!normalizedPath.includes(defaultVersion)) {
filePaths.splice(i, 1);
}
}
}
Bug Behavior
If the workspace or temporary directory path where Librarian/generator runs happens to contain the substring defaultVersion (for example, /tmp/upgrade-nodejs-v2Mp8W containing "v2"), normalizedPath.includes("v2") evaluates to true for all API versions (including v3).
As a result:
!normalizedPath.includes(defaultVersion)evaluates tofalse.v3fixture files are not filtered out.v3sample fixtures overwritev2sample fixtures, generating unintended client diffs (e.g.,packages/google-iam/system-test/fixtures/sample/src/index.tsexportingAccessPoliciesClientinstead ofPoliciesClient).
Reference PR & CI Breakage
This issue was observed during Librarian version upgrade in:
- Pull Request: https://github.com/googleapis/google-cloud-node/pull/9340
- Affected Commit:
559da2d4(wheremktemp -dgenerated/tmp/upgrade-nodejs-v2Mp8W) - CI Failure: https://github.com/googleapis/google-cloud-node/actions/runs/34998266744/job/104479939975?pr=9340 (clean CI runner without
v2in path did not generate thev3diffs, causing agit diffdiscrepancy).
Suggested Fix
Match the version directory boundary specifically rather than performing an unconstrained substring check across the absolute path:
const versionDirRegex = new RegExp(`(^|/)${defaultVersion}(/|$)`);
if (systemTestRegex.test(normalizedPath) && !versionDirRegex.test(normalizedPath)) {
filePaths.splice(i, 1);
}
- 主要语言
- TypeScript
- 星标
- 3.2k
- 派生
- 723
- 平均合并
- 2 天 18 小时
- 30 天内合并 PR
- 172
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-cloud-node 的其他 Issue
-
api: spanner
难度 2/5 1-3 小时 新手友好度 78/100
googleapis/google-cloud-node#9513 ·
维护者通常 1 天内回复
-
google-auth-library: JWT with a JSON keyFile signs without iss since 10.6.1 (invalid_grant: account not found)可能已有人在做 @Marinski 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
googleapis/google-cloud-node#9469 ·
维护者通常 1 天内回复
-
priority: p1 samples type: bug
难度 2/5 1-3 小时 新手友好度 68/100
googleapis/google-cloud-node#9367 ·
维护者通常 1 天内回复
-
TransferManager uploadFileInChunks does not error when aborted可能已有人在做 @Om-singhaI 于 47 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
googleapis/google-cloud-node#9193 ·
维护者通常 1 天内回复
-
google-auth-library: getErrorFromOAuthErrorResponse() copies stack as non-writable, breaking error decoration in consumers可能已有人在做 @Om-singhaI 于 47 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
googleapis/google-cloud-node#9155 ·
维护者通常 1 天内回复
查看 googleapis/google-cloud-node 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
lukilabs/beautiful-mermaid#160 ·
-
难度 2/5 1-3 小时 新手友好度 66/100
rescript-lang/rescript-lang.org#1420 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
chthollyphile/folia-major#520 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
databuddy-analytics/Databuddy#1106 ·
维护者通常 1 天内回复