Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

bug(gapic-node-processing): setOnlyDefaultSystemTests incorrectly matches substring on absolute path

未关闭 适合新手
#9,342 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@rootkiller6788 已经在做这个了。

开始于 2026年10月5日。

  • #9516 来自 @rootkiller6788 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

从 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:

  1. !normalizedPath.includes(defaultVersion) evaluates to false.
  2. v3 fixture files are not filtered out.
  3. v3 sample fixtures overwrite v2 sample fixtures, generating unintended client diffs (e.g., packages/google-iam/system-test/fixtures/sample/src/index.ts exporting AccessPoliciesClient instead of PoliciesClient).
Reference PR & CI Breakage

This issue was observed during Librarian version upgrade in:

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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleapis/google-cloud-node 的其他 Issue

查看 googleapis/google-cloud-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。