googleapis / googleapis/release-please

Bug: group-pull-request-title-pattern with ${component} causes 'Cannot read properties of undefined (reading replace)'

Open
#2,654 0 comments 0 reactions 1 assignee Claimed by @chingor13 View on GitHub
priority: p3 type: bug
Dominant language
TypeScript
Stars
7.5k
Forks
588
Avg merge
12h 16m
Merged PRs (30d)
7

Description

## Environment

- release-please version: 16.x (via abridgeai/release-please-demo action)
- Node.js version: 20
- Running via GitHub Actions

## Description

Using `group-pull-request-title-pattern` with `${component}` in a monorepo config causes the error:

```
TypeError: Cannot read properties of undefined (reading 'replace')
at safeBranchName (branch-name.js:214:23)
at BranchName.ofGroupTargetBranch (branch-name.js:63:93)
```

This appears related to #2414 but with a different trigger.

## Steps to Reproduce

1. Create a monorepo with multiple packages using different release types (python, helm, simple)
2. Add this to `release-please-config.json`:

```json
{
"bootstrap-sha": "...",
"always-update": true,
"separate-pull-requests": false,
"group-pull-request-title-pattern": "chore: release ${component}",
"packages": {
".": {
"release-type": "python",
"package-name": "my_app"
},
"helm/my-chart": {
"release-type": "helm",
"package-name": "my_chart"
},
"docker/webserver": {
"release-type": "simple",
"package-name": "webserver",
"extra-files": ["VERSION"]
}
}
}
```

3. Push a commit with conventional commit prefix (e.g., `fix: something`)
4. Release Please fails with the error above

## Expected Behavior

Release Please should create a grouped release PR with the title pattern applied.

## Actual Behavior

Release Please crashes with:
```
##[error]release-please failed: Cannot read properties of undefined (reading 'replace')
```

The error occurs in `safeBranchName()` at `branch-name.js:214:23`, called from `BranchName.ofGroupTargetBranch()`.

## Workaround

Removing both settings fixes the issue:
- `"separate-pull-requests": false`
- `"group-pull-request-title-pattern": "chore: release ${component}"`

## Analysis

The `${component}` variable appears to be undefined in certain code paths when:
1. Multiple packages exist with different release types
2. `separate-pull-requests: false` is set (grouped PRs)
3. The `simple` release type is used alongside other types

The `safeBranchName()` function tries to call `.replace()` on an undefined value, suggesting the component name is not being passed correctly to the branch naming logic.

## Related Issues

- #2414 - Same error but different trigger (LinkedVersions plugin)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.