Skip to content

Make API_REQUEST_LIMIT configurable to support CodeArtifact gem hosts #9345

@kjacksonsoftware

Description

@kjacksonsoftware

Describe the problem as clearly as you can

The current API_REQUEST_LIMIT of 100 in bundler 4.0.6 is incompatible with some gem hosts, particularly CodeArtifact.

Using rubygems 4.0.6 and bundler 4.0.6 I get the following error when attempting to update a gem using gem update [gemname]:

Fetching gem metadata from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/.
Retrying dependency api due to error (2/4): Bundler::HTTPError Gem::Net::HTTPBadRequest: {"errors":[{"detail":"The number of dependencies in the request 69 exceeded the limit of 50 per request."}]}

I left rubygems at version 4.0.6 and reverted bundler to 2.7.2 and did not see this issue.

Doing some research, I noticed #9071. I tried temporarily changing the value of API_REQUEST_LIMIT back to 50 in bundler 4.0.6 and that resolved the issue.

I suspect that some package hosts have non-configurable quotas that this limit must match, meaning that the limit needs to be configurable for those cases. Ideally the failure mode would also make the source more clear, since it was not obvious to me that the error detail was coming from the gem host and not rubygems or bundler.

Did you try upgrading rubygems & bundler?

Yes

Post steps to reproduce the problem

Using ruby installed through RVM on MacOS 26.3 or Ubuntu.
Rubygems 4.0.6
Bundler 4.0.6

In gemfile, set source to a CodeArtifact repository.

Run bundle install or bundle update to trigger fetching a gem not already installed on your system.

Which command did you run?

bundle install or bundle update [gemname]

What were you expecting to happen?

Gems to be installed or updated.

What happened instead?

Fetching gem metadata from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/.
Retrying dependency api due to error (2/4): Bundler::HTTPError Gem::Net::HTTPBadRequest: {"errors":[{"detail":"The number of dependencies in the request 69 exceeded the limit of 50 per request."}]}

Retrying dependency api due to error (3/4): Bundler::HTTPError Gem::Net::HTTPBadRequest: {"errors":[{"detail":"The number of dependencies in the request 69 exceeded the limit of 50 per request."}]}

Retrying dependency api due to error (4/4): Bundler::HTTPError Gem::Net::HTTPBadRequest: {"errors":[{"detail":"The number of dependencies in the request 69 exceeded the limit of 50 per request."}]}



Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/ due to underlying error <bad response Not Found 404 (https://aws:REDACTED@REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/specs.4.8.gz)>

Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/ due to underlying error <bad response Not Found 404 (https://aws:REDACTED@REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/specs.4.8.gz)>

Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/ due to underlying error <bad response Not Found 404 (https://aws:REDACTED@REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/specs.4.8.gz)>

Could not fetch specs from https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/ due to underlying error <bad response Not Found 404
(https://aws:REDACTED@REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/specs.4.8.gz)>

Note the final 404 is already reported in #8244

If not included with the output of your command, run bundle env and paste the output below

Environment

Bundler             4.0.6
  Platforms         ruby, arm64-darwin-24
Ruby                3.4.3p32 (2025-04-14 revision d0b7e5b6a04bde21ca483d20a1546b28b401c2d4) [arm64-darwin-24]
  Full Path         /home/user/.rvm/rubies/ruby-3.4.3/bin/ruby
  Config Dir        /home/user/.rvm/rubies/ruby-3.4.3/etc
RubyGems            4.0.6
  Gem Home          /home/user/.rvm/gems/ruby-3.4.3
  Gem Path          /home/user/.rvm/gems/ruby-3.4.3:/home/user/.rvm/rubies/ruby-3.4.3/lib/ruby/gems/3.4.0
  User Home         /home/user
  User Path         /home/user/.local/share/gem/ruby/3.4.0
  Bin Dir           /home/user/.rvm/gems/ruby-3.4.3/bin
Tools               
  Git               2.50.1 (Apple Git-155)
  RVM               1.29.12-next (master)
  rbenv             not installed
  chruby            not installed
  rubygems-bundler  (1.4.5)

Bundler Build Metadata

Timestamp  2026-02-05
Git SHA    0947d9cf5b

Bundler settings

https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/
  Set for your local app (/Users/user/Documents/workspace/project/.bundle/config): "aws:[REDACTED]"

Gemfile

Gemfile

# frozen_string_literal: true

source 'https://rubygems.org'

ruby file: '.ruby-version'

# Dotenv loads config options from environment variables. Other gems (ie carrierwave) which reference config options
# at startup need to load after dotenv-rails as a result, so we put it first in the list.
gem 'dotenv', '~> 3.1.8', require: 'dotenv/load'

# We store our private/internal gems here
source 'https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/' do
...
end

Gemfile.lock


GEM
  remote: https://REDACTED.d.codeartifact.us-east-2.amazonaws.com/ruby/REDACTED/
  specs:
...

GEM
  remote: https://rubygems.org/
  specs:
...

PLATFORMS
  arm64-darwin-21
  arm64-darwin-23
  arm64-darwin-24
  x64-mingw32
  x86-mingw32
  x86_64-darwin-18
  x86_64-darwin-19
  x86_64-darwin-20
  x86_64-linux

DEPENDENCIES
...

RUBY VERSION
  ruby 3.4.3p32

BUNDLED WITH
  4.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions