Skip to content

Commit fcc03ef

Browse files
authored
Merge pull request #9492 from jneen/bugfix.error-on-missing-checksum
Gracefully handle missing checksums in Compact Index
2 parents 41e5474 + 234e2b7 commit fcc03ef

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

bundler/lib/bundler/compact_index_client/parser.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def gem_parser
7171
# This method gets called at least once for every gem when parsing versions.
7272
def parse_version_checksum(line, checksums)
7373
return unless (name_end = line.index(" ")) # Artifactory bug causes blank lines in artifactor index files
74-
return unless (checksum_start = line.index(" ", name_end + 1) + 1)
74+
checksum_start = line.index(" ", name_end + 1)
75+
return unless checksum_start
76+
checksum_start += 1
77+
7578
checksum_end = line.size - checksum_start
7679

7780
line.freeze # allows slicing into the string to not allocate a copy of the line

spec/bundler/compact_index_client/parser_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,17 @@ def set_info_data(name, value)
233233
VERSIONS
234234
expect(parser.info("a")).to eq(a_result)
235235
end
236+
237+
it "handles lines without a checksum" do
238+
compact_index.versions = <<~VERSIONS
239+
created_at: 2024-05-01T00:00:04Z
240+
---
241+
a 1.0.0,1.0.1,1.1.0 aaa111
242+
b 2.0.0,2.0.0-java
243+
c 3.0.0,3.0.3,3.3.3 ccc333
244+
VERSIONS
245+
246+
expect(parser.info("a")).to eq(a_result)
247+
end
236248
end
237249
end

0 commit comments

Comments
 (0)