Skip to content

fix(bundle_fetch): handle null requirements in RubyGems API#350

Merged
p0deje merged 2 commits intobazel-contrib:mainfrom
noahkawasakigoogle:noah/jar-bug
Mar 3, 2026
Merged

fix(bundle_fetch): handle null requirements in RubyGems API#350
p0deje merged 2 commits intobazel-contrib:mainfrom
noahkawasakigoogle:noah/jar-bug

Conversation

@noahkawasakigoogle
Copy link
Contributor

RubyGems API v2 sometimes returns "requirements": null instead of an empty list. Since Starlark's json.decode maps JSON null to None, attempting to iterate over requirements was failing.

This change ensures that _fetch_gem_requirements always returns an iterable list.

Additionally:

  • Exported jars_downloader_internal to allow unit testing of private functions.
  • Added comprehensive unit tests in ruby/tests/jars_downloader_tests.bzl.
  • Registered the new test suite in ruby/tests/BUILD.

RubyGems API v2 sometimes returns `"requirements": null` instead of
an empty list. Since Starlark's `json.decode` maps JSON `null` to `None`,
attempting to iterate over `requirements` was failing.

This change ensures that `_fetch_gem_requirements` always returns an
iterable list.

Additionally:
- Exported `jars_downloader_internal` to allow unit testing of private
  functions.
- Added comprehensive unit tests in `ruby/tests/jars_downloader_tests.bzl`.
- Registered the new test suite in `ruby/tests/BUILD`.

Verified with `bazelisk test //ruby/tests/...`.
@noahkawasakigoogle
Copy link
Contributor Author

noahkawasakigoogle commented Mar 3, 2026

@p0deje

@amarkowitz FYI this bug blocked us from upgrading past 0.22.0.

@p0deje p0deje merged commit d0a5bca into bazel-contrib:main Mar 3, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants