Skip to content

fix: tolerate <details> blocks without a summary when re-parsing release pull request bodies - #2885

Open
johnitvn wants to merge 1 commit into
googleapis:mainfrom
johnitvn:fix/tolerate-summaryless-details-blocks
Open

fix: tolerate <details> blocks without a summary when re-parsing release pull request bodies#2885
johnitvn wants to merge 1 commit into
googleapis:mainfrom
johnitvn:fix/tolerate-summaryless-details-blocks

Conversation

@johnitvn

Copy link
Copy Markdown

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2884 🦕


Problem

extractMultipleReleases() re-parses release pull request bodies with node-html-parser. A commit subject may legitimately contain a token like `<details>` inside an inline code span (which htmlEscape() intentionally leaves untouched, see #2801). The HTML parser does not understand markdown, so that token becomes a real <details> element without a <summary> child, and the current code dereferences it unconditionally:

const summaryNode = detail.getElementsByTagName('summary')[0];
const summary = summaryNode?.textContent;
const match = summary.match(SUMMARY_PATTERN); // TypeError when no <summary>

This hard-crashes every subsequent release-please run (Cannot read properties of undefined (reading 'match')) until someone merges or manually edits the open release pull request. Reproduction and full stack trace in #2884; observed in the wild on 17.6.0 and verified still present in 17.11.1.

Fix

Skip <details> blocks that have no <summary>, with a warning:

const summaryNode = detail.getElementsByTagName('summary')[0];
if (!summaryNode) {
  logger.warn(
    'found a <details> block without a <summary>, skipping it - ...'
  );
  continue;
}

Generated blocks always carry a <summary>, so real multi-component parsing is unchanged. For single-package bodies containing such a stray token, extraction now correctly falls back to the existing single-release path instead of throwing.

Tests

  • should tolerate a <details> element missing a <summary> - a body whose changelog bullet contains a backticked <details> token parses to one release via the fallback path (previously crashed with exactly the reported TypeError)
  • should keep parsing valid components around a <details> element missing a <summary> - injecting a stray summary-less block into the multi-component fixture still yields all valid components
  • Full suite: 1211 passing, gts check clean, coverage not decreased

…ase pull request bodies

Commit subjects can legitimately contain tokens like `<details>` inside
inline code spans, and htmlEscape intentionally leaves those untouched.
When such a body is later re-parsed by extractMultipleReleases, the HTML
parser sees a real <details> element that has no <summary>, and the code
dereferenced it unconditionally, crashing with:

    TypeError: Cannot read properties of undefined (reading 'match')

This blocks every subsequent release-please run until the pull request
is merged or its body is edited by hand.

Skip summary-less details blocks with a warning so parsing falls back to
the single-release path, and valid components around such blocks keep
parsing as before.
@johnitvn
johnitvn requested review from a team as code owners August 22, 2026 18:18
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Aug 22, 2026
@google-cla

google-cla Bot commented Aug 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@johnitvn

Copy link
Copy Markdown
Author

I have already signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

1 participant