Skip to content

Commit

Permalink
Fix fetching a nil sourcediff
Browse files Browse the repository at this point in the history
This fixes an "undefined method `reduce' for nil:NilClass" error.

The fetch has a default option for when the `:sourcediff` key does not
exist, but if the sourcediff is actually nil, the reduce fails.

This PR adds a default empty array for the reduce to work.
  • Loading branch information
danidoni committed Feb 9, 2024
1 parent 0e6498f commit 8651720
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def prepare_request_data
@staging_status = staging_status(@bs_request, target_project) if Staging::Workflow.find_by(project: target_project)

# Collecting all issues in a hash. Each key is the issue name and the value is a hash containing all the issue details.
@issues = @action.fetch(:sourcediff, []).reduce({}) { |accumulator, sourcediff| accumulator.merge(sourcediff.fetch('issues', {})) }
@issues = (@action.fetch(:sourcediff, []) || []).reduce({}) { |accumulator, sourcediff| accumulator.merge(sourcediff.fetch('issues', {})) }

# retrieve a list of all package maintainers that are assigned to at least one target package
@package_maintainers = target_package_maintainers
Expand Down

0 comments on commit 8651720

Please sign in to comment.