From 6bb8517ba984f93deceab6414cb528439088c7a1 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 19 Aug 2026 12:01:56 -0400 Subject: [PATCH 1/2] feat(get_prs_between_tags): add opt-in fail_on_error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The action rescues every StandardError from `generate_release_notes` and returns the message as the changelog, so a transient API failure yields a GitHub Release whose notes read "❌ Error computing the list of PRs…". That is the right default for callers that create the release first and would rather ship degraded notes than fail the lane. It is the wrong one for callers that push the tag and then create the release from the computed notes: there the failure needs to stop the lane while a re-run is still cheap. Defaults to false, so existing callers are unaffected. Co-Authored-By: Claude Opus 5 (1M context) --- CHANGELOG.md | 2 +- .../actions/common/get_prs_between_tags.rb | 11 ++++ spec/get_prs_between_tags_spec.rb | 50 ++++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5597d5cf..cc77fa710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ _None_ ### New Features -_None_ +- `get_prs_between_tags` accepts a `fail_on_error:` parameter. When `true`, a failure to compute the changelog raises instead of being returned as the changelog text, so callers that publish a GitHub Release only after the action succeeds can stop rather than publish notes reading `❌ Error computing the list of PRs…`. Defaults to `false`, preserving the existing behavior. [#772] ### Bug Fixes diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb index f396dc8d7..e68104c01 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb @@ -25,6 +25,8 @@ def self.run(params) config_file_path: config_file_path ) rescue StandardError => e + raise if params[:fail_on_error] + error_msg = "❌ Error computing the list of PRs since #{previous_tag || 'last release'}: `#{e.message}`" UI.important(error_msg) error_msg # Use error message as GitHub Release body to help us be aware of what went wrong. @@ -102,6 +104,15 @@ def self.available_options 'See https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuration-options', optional: true, type: String), + FastlaneCore::ConfigItem.new(key: :fail_on_error, + description: 'Whether to fail the lane if the changelog cannot be computed. ' \ + 'When `false` (the default), the error message is returned as the changelog itself, ' \ + 'so that it ends up visible in the GitHub Release body. ' \ + 'Set this to `true` if the caller publishes the release only after this action succeeds, ' \ + 'and would rather stop than publish a release whose notes are an error message', + optional: true, + default_value: false, + type: Boolean), Fastlane::Helper::GithubHelper.github_token_config_item, ] end diff --git a/spec/get_prs_between_tags_spec.rb b/spec/get_prs_between_tags_spec.rb index 1136d2639..0c63fdb2f 100644 --- a/spec/get_prs_between_tags_spec.rb +++ b/spec/get_prs_between_tags_spec.rb @@ -107,8 +107,7 @@ def test_with_params(target_commitish: nil, previous_tag: nil, configuration_fil end describe 'error handling' do - def test_with_params(target_commitish: nil, previous_tag: nil, configuration_file_path: nil, error_msg: 'API Failure') - # Arrange + def stub_failing_api_call(target_commitish: nil, previous_tag: nil, configuration_file_path: nil, error_msg: 'API Failure') allow(client).to receive(:post).with( "repos/#{test_repo}/releases/generate-notes", config_file_path: configuration_file_path, @@ -116,6 +115,16 @@ def test_with_params(target_commitish: nil, previous_tag: nil, configuration_fil tag_name: test_tag_name, target_commitish: target_commitish || test_head_ref ).and_raise(StandardError, error_msg) + end + + def test_with_params(target_commitish: nil, previous_tag: nil, configuration_file_path: nil, error_msg: 'API Failure') + # Arrange + stub_failing_api_call( + target_commitish: target_commitish, + previous_tag: previous_tag, + configuration_file_path: configuration_file_path, + error_msg: error_msg + ) # Act result = run_described_fastlane_action( @@ -154,5 +163,42 @@ def test_with_params(target_commitish: nil, previous_tag: nil, configuration_fil error_msg: '400 - Invalid previous_tag parameter' ) end + + context 'when `fail_on_error` is enabled' do + it 'raises instead of returning the error message as the changelog' do + # Arrange + stub_failing_api_call(previous_tag: '12.2', error_msg: 'API Failure') + + # Act & Assert + expect do + run_described_fastlane_action( + github_token: test_token, + repository: test_repo, + tag_name: test_tag_name, + previous_tag: '12.2', + fail_on_error: true + ) + end.to raise_error(StandardError, 'API Failure') + end + end + + context 'when `fail_on_error` is explicitly disabled' do + it 'returns the error message as the changelog, like the default does' do + # Arrange + stub_failing_api_call(previous_tag: '12.2', error_msg: 'API Failure') + + # Act + result = run_described_fastlane_action( + github_token: test_token, + repository: test_repo, + tag_name: test_tag_name, + previous_tag: '12.2', + fail_on_error: false + ) + + # Assert + expect(result).to eq('❌ Error computing the list of PRs since 12.2: `API Failure`') + end + end end end From 0b90010dce6cb4a39b8b2fb6147eb213f9c0836f Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 19 Aug 2026 12:30:54 -0400 Subject: [PATCH 2/2] docs: Reduce `fail_on_error:` CHANGELOG entry verbosity Avoid unnecessary explanation in the CHANGELOG. Co-authored-by: Olivier Halligon --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc77fa710..7aa211785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ _None_ ### New Features -- `get_prs_between_tags` accepts a `fail_on_error:` parameter. When `true`, a failure to compute the changelog raises instead of being returned as the changelog text, so callers that publish a GitHub Release only after the action succeeds can stop rather than publish notes reading `❌ Error computing the list of PRs…`. Defaults to `false`, preserving the existing behavior. [#772] +- `get_prs_between_tags` now accepts a `fail_on_error:` parameter. [#772] ### Bug Fixes