googleapis / googleapis/release-please

bug: `pull-request-header` and `pull-request-footer` set to `""` fall back to defaults due to `||` instead of `??`

Open
#2,696 0 comments 1 reaction 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

## Bug

Setting `"pull-request-header": ""` in `release-please-config.json` does not remove the default header. The PR body still contains `:robot: I have created a release *beep* *boop*`.

## Root cause

In [`src/util/pull-request-body.ts`](https://github.com/googleapis/release-please/blob/main/src/util/pull-request-body.ts), the constructor uses `||` for both header and footer:

```typescript
this.header = options?.header || DEFAULT_HEADER;
this.footer = options?.footer || DEFAULT_FOOTER;
```

Since empty string is falsy in JavaScript, `"" || DEFAULT_HEADER` evaluates to `DEFAULT_HEADER`. These should use nullish coalescing (`??`) to only fall back for `null`/`undefined`:

```typescript
this.header = options?.header ?? DEFAULT_HEADER;
this.footer = options?.footer ?? DEFAULT_FOOTER;
```

## Steps to reproduce

1. Set `"pull-request-header": ""` and/or `"pull-request-footer": ""` in `release-please-config.json`
2. Run release-please to create/update a release PR
3. Observe the PR body still contains the default header/footer

## Expected behavior

An empty string should be respected as an intentional override, producing no header/footer.

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.