Rescue errors in metadata_cascades_for_dep to prevent PR message loss#14905
Rescue errors in metadata_cascades_for_dep to prevent PR message loss#14905yeikel wants to merge 2 commits into
Conversation
0636bf6 to
f6ae25e
Compare
f6ae25e to
cd291c0
Compare
afa8d6b to
44dd26c
Compare
44dd26c to
da4c1b0
Compare
There was a problem hiding this comment.
Pull request overview
Rescues errors raised while building the metadata cascade section of a PR message, so that transient network failures (e.g., GitHub API timeouts) no longer wipe out the entire PR body. The error is logged via the existing suppress_error helper and an empty string is returned, allowing the rest of the message to be assembled.
Changes:
- Wrap
metadata_cascades_for_depbody in arescue StandardErrorthat callssuppress_errorand returns"". - Update an existing spec that previously asserted a blank message on SocketError to now expect the intro line.
- Add a new spec stubbing
MetadataPresenter#to_sto raiseSocketError, asserting the PR body still contains the intro line.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| common/lib/dependabot/pull_request_creator/message_builder.rb | Adds rescue in metadata_cascades_for_dep to suppress errors and return an empty cascade. |
| common/spec/dependabot/pull_request_creator/message_builder_spec.rb | Updates existing SocketError expectation and adds a new test simulating GitHub unreachable during metadata fetching. |
da4c1b0 to
5e012fb
Compare
|
@yeikel , thanks for raising this PR, and sorry for delay. I have two requests before merge: Thanks for working on this — the fix looks to be in the right place. metadata_cascades_for_dep is building optional enrichment content like changelog, releases, and commits. Failures there should not cause the entire PR body to be dropped. Right now, if MetadataPresenter#to_s raises, the exception bubbles up to pr_message, which rescues at the top level and returns only the header/footer or an empty body. That matches the bug reported in #14904. Handling the error inside metadata_cascades_for_dep, logging it via suppress_error, and returning "" seems like the correct degradation behavior: preserve the main PR intro/body and omit only the metadata sections. Before this is merged, I’d like to see two follow-ups: Add one more regression test for a grouped or multi-dependency PR make one dependency’s metadata cascade raise the minimal manifest used use a minimal Maven project with a public dependency |
a620515 to
bcdba0b
Compare
When metadata_cascades_for_dep encounters a network error (e.g., GitHub API timeout), it now gracefully handles the failure by returning an empty string and logging the error via suppress_error. This allows the PR message to be assembled without the metadata cascade sections (changelog, commits, releases) but still includes the important intro line and message content. Previously, any error in metadata fetching would propagate up to pr_message's top-level rescue, causing the entire PR body to be discarded and replaced with just the header and footer. Fixes dependabot#14904
Verifies that when one dependency's metadata cascade raises in a multi-dependency PR, the other dependency's metadata is unaffected and the overall PR message still renders.
bcdba0b to
228f3dc
Compare
Thanks for the detailed review, @v-HaripriyaC! Both requests are addressed in the latest commit:
Added a new context inside when updating multiple dependencies in message_builder_spec.rb. It stubs only statesman's CHANGELOG.md endpoint to raise SocketError, then asserts three things independently:
Updated the PR description with:
|
What are you trying to accomplish?
When
metadata_cascades_for_depencounters a network error (e.g., GitHub API timeout), it now gracefully handles the failure by returning an empty string and logging the error viasuppress_error. This allows the PR message to be assembled without the metadata cascade sections (changelog, commits, releases) but still includes the important intro line and message content.Previously, any error in metadata fetching would propagate up to
pr_message's top-level rescue, causing the entire PR body to be discarded and replaced with just the header and footer (or an empty string).Fixes #14904
Reproduction steps
Minimal setup - a Maven project with a public GitHub-hosted dependency:
How to trigger the bug - block
api.github.comduring PR message generation to simulate a GitHub API timeout:Updater CLI flow:
Observed pr-body before this patch:
The error
SocketError: Failed to open TCP connection to api.github.com:443was raised insideMetadataPresenter#to_s, propagated throughmetadata_cascades_for_depup topr_message's top-level rescue, which returned onlysuffixed_pr_message_header + prefixed_pr_message_footer. When no custom header/footer is configured, this produces an empty string.Observed pr-body after this patch:
The intro line is preserved. Metadata sections (changelog, commits, releases) are omitted for the affected dependency only.
Test-level reproduction (no network blocking needed):
Both cases are covered by the new regression tests in
message_builder_spec.rb.Anything you want to highlight for special attention from reviewers?
metadata_cascades_for_dep, notpr_message, so only the enrichment content (changelog, commits, releases) for the failing dependency is dropped. The intro/body is preserved.How will you know you've accomplished your goal?
The existing and new tests pass, including:
metadata_cascades_for_depraises, PR message retains introMetadataPresenter#to_sraises directly, PR message retains introChecklist