Skip to content

Commit 12ed9b1

Browse files
committed
be more resilient to bad data when updating contributors
When trying to update all contributor data, it will fail because there are some broken releases in the index. While those should be fixed, they shouldn't cause the contributor script to fail.
1 parent 232b751 commit 12ed9b1

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/MetaCPAN/Script/Role/Contributor.pm

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,28 @@ sub update_contributors {
2525
},
2626
);
2727

28-
my $bulk = $self->es->bulk_helper( es_doc_path('contributor') );
28+
my $report = sub {
29+
my ( $action, $result, $i ) = @_;
30+
if ( $i == 0 ) {
31+
log_info {'flushing contributor updates'};
32+
}
33+
};
34+
35+
my $bulk = $self->es->bulk_helper(
36+
es_doc_path('contributor'),
37+
on_success => $report,
38+
on_error => $report,
39+
);
40+
41+
log_info { 'updating contributors for ' . $scroll->total . ' releases' };
2942

3043
while ( my $release = $scroll->next ) {
44+
my $source = $release->{_source};
45+
my $name = $source->{name};
46+
if ( !( $name && $source->{author} && $source->{distribution} ) ) {
47+
Dlog_warn {"found broken release: $_"} $release;
48+
next;
49+
}
3150
log_debug { 'updating contributors for ' . $release->{_source}{name} };
3251
my $actions = $self->release_contributor_update_actions(
3352
$release->{_source} );

0 commit comments

Comments
 (0)