Skip to content

[JS] Git commands used in changelog generation are fragile and may cause silent failures #14589

@kazrael2119

Description

@kazrael2119

Background
During changelog generation, the tool reads two types of files from a previously released package version:

  • review/*.api.md — used for API diff to detect breaking changes and new features
  • CHANGELOG.md — used as the base for the new changelog entry
    The primary path is to extract these files from the npm tarball via npm pack ${packageName}@${version}. However, when the files are not found in the tarball (e.g., review/ directory is not in the package's files field), the code falls back to reading them directly from the local git repository using git commands:
// In npmUtils.ts — tryCreateLastestStableNpmViewFromGithub
git --no-pager show ${tag}:${sdkFilePath}           // reads CHANGELOG.md from release tag
git --no-pager show ${tag}:${nodeApiFilePath}        // reads -node.api.md from release tag
git --no-pager show ${tag}:${standardApiFilePath}    // reads .api.md from release tag

// Additional git commands used to validate before calling the above
git tag -l ${tag}                                   // check if release tag exists locally
git ls-tree -d ${tag} ${relativePath}               // check if directory exists in tag

Problem
These git commands are not reliable in standard CI pipeline environments:

  • CI pipelines typically use shallow clones (--depth=1), meaning release tags from previous versions are not fetched locally
  • git tag -l ${tag} returns empty even when the tag exists remotely → incorrect false → fallback skipped
  • git ls-tree -d ${tag} ... fails silently → wrong assumption about package structure
  • git --no-pager show ${tag}:... produces empty content → API diff falls back to empty/default → breaking changes or new features suppressed in the generated changelog

Impact

Image

but in the next generation
it can't update the version (PS: 1.0.0-beta.1 is a default value in codegen) after re-generation.
and in the next generation pipeline we can see it read nothing from git tag command, but it could read it in the first generation pipeline

@jeremymeng could we still export ./review and CHANGELOG.md in packed packages for the changelog generation?

Metadata

Metadata

Assignees

Labels

needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions