From 234e2b7d5f0b8681409037544d00e8f3fdeb6238 Mon Sep 17 00:00:00 2001 From: jneen Date: Sat, 18 Apr 2026 12:18:50 -0400 Subject: [PATCH] Gracefully handle missing checksums in Compact Index --- bundler/lib/bundler/compact_index_client/parser.rb | 5 ++++- spec/bundler/compact_index_client/parser_spec.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bundler/lib/bundler/compact_index_client/parser.rb b/bundler/lib/bundler/compact_index_client/parser.rb index 43581fd7efe5..ad0d17ed4a4a 100644 --- a/bundler/lib/bundler/compact_index_client/parser.rb +++ b/bundler/lib/bundler/compact_index_client/parser.rb @@ -71,7 +71,10 @@ def gem_parser # This method gets called at least once for every gem when parsing versions. def parse_version_checksum(line, checksums) return unless (name_end = line.index(" ")) # Artifactory bug causes blank lines in artifactor index files - return unless (checksum_start = line.index(" ", name_end + 1) + 1) + checksum_start = line.index(" ", name_end + 1) + return unless checksum_start + checksum_start += 1 + checksum_end = line.size - checksum_start line.freeze # allows slicing into the string to not allocate a copy of the line diff --git a/spec/bundler/compact_index_client/parser_spec.rb b/spec/bundler/compact_index_client/parser_spec.rb index 1f6b9e593bcd..6015f66f33a7 100644 --- a/spec/bundler/compact_index_client/parser_spec.rb +++ b/spec/bundler/compact_index_client/parser_spec.rb @@ -233,5 +233,17 @@ def set_info_data(name, value) VERSIONS expect(parser.info("a")).to eq(a_result) end + + it "handles lines without a checksum" do + compact_index.versions = <<~VERSIONS + created_at: 2024-05-01T00:00:04Z + --- + a 1.0.0,1.0.1,1.1.0 aaa111 + b 2.0.0,2.0.0-java + c 3.0.0,3.0.3,3.3.3 ccc333 + VERSIONS + + expect(parser.info("a")).to eq(a_result) + end end end