豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

add support for hex aliases#14225

Merged
robaiken merged 2 commits intodependabot:mainfrom
efcasado:feat-elixir-hex-alias
Feb 20, 2026
Merged

add support for hex aliases#14225
robaiken merged 2 commits intodependabot:mainfrom
efcasado:feat-elixir-hex-alias

Conversation

@efcasado
Copy link
Copy Markdown
Contributor

@efcasado efcasado commented Feb 19, 2026

What are you trying to accomplish?

Dependabot failed to detect updates for Elixir dependencies using the :hex option to alias the package name. The off_broadway_pulsar project is an example, where pulsar-elixir is defined as a dependency as follows

{:pulsar, "~> 2.8.7", hex: :pulsar_elixir}

Prior to this change, the local app name (ie. :pulsar) was used for hex.pm API lookups instead of the actual package name (ie. :pulsar_elixir), causing version checks and metadata lookups to query the wrong package.

Anything you want to highlight for special attention from reviewers?

The change should be backward-compatible. We've introduced a new field, ie. package_name, which defaults to the local application name unless an alias is specified (using the :hex option). When present, the alias is propagated as metadata to other components. The metadata finder has been updated to rely on this new field.

By using a dedicated field, we maintain a clear separation between how the application is represented in the lockfile and how it is handled in Hex (ie. the package manager).

How will you know you've accomplished your goal?

Dependabot will detect updates for dependencies using aliases. For example, pulsar-elixir in off_broadway_pulsar.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@github-actions github-actions bot added the L: elixir:hex Elixir packages via hex label Feb 19, 2026
@efcasado efcasado force-pushed the feat-elixir-hex-alias branch from 4358c4b to 0e420ef Compare February 19, 2026 19:12

@dependency_url = T.let("https://hex.pm/api/packages/#{dependency.name}", T.nilable(String))
@dependency_url = T.let(
"https://hex.pm/api/packages/#{dependency.metadata[:hex_package] || dependency.name}",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency.name fallback is only needed because tests are calling Dependency.new directly. That is, the parser is being bypassed (see here).

@efcasado efcasado marked this pull request as ready for review February 19, 2026 19:19
@efcasado efcasado requested a review from a team as a code owner February 19, 2026 19:19
Copilot AI review requested due to automatic review settings February 19, 2026 19:19
@efcasado efcasado force-pushed the feat-elixir-hex-alias branch from 0e420ef to d88a173 Compare February 19, 2026 19:19
@efcasado efcasado changed the title [elixir] add support for hex aliases add support for hex aliases Feb 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Hex package alias support for Elixir dependencies declared with the :hex option (e.g. {:pulsar, "~> 2.8.7", hex: :pulsar_elixir}), ensuring Dependabot queries hex.pm using the actual package name rather than the local app name.

Changes:

  • Extend the Elixir helper output to include a resolved package_name for each dependency (alias-aware).
  • Persist the resolved Hex package name onto Dependabot::Dependency via metadata[:hex_package] during parsing.
  • Update Hex registry lookups (package details + metadata finder) to prefer metadata[:hex_package] over dependency.name, and add fixtures/specs covering the alias behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
hex/helpers/lib/parse_deps.exs Emits package_name based on dep.opts[:hex] to capture Hex aliases.
hex/lib/dependabot/hex/file_parser.rb Stores the parsed package_name into dependency metadata (:hex_package).
hex/lib/dependabot/hex/package/package_details_fetcher.rb Uses metadata[:hex_package] for hex.pm package API lookups.
hex/lib/dependabot/hex/metadata_finder.rb Uses metadata[:hex_package] for hex.pm metadata API lookups.
hex/spec/fixtures/mixfiles/hex_alias New fixture Mixfile demonstrating hex: alias usage.
hex/spec/fixtures/lockfiles/hex_alias New fixture lockfile showing alias in the :hex lock tuple.
hex/spec/dependabot/hex/file_parser_spec.rb Adds parsing assertions for aliased and non-aliased deps.
hex/spec/dependabot/hex/package/package_details_fetcher_spec.rb Adds a spec asserting API lookup uses the aliased package name.
hex/spec/dependabot/hex/metadata_finder_spec.rb Adds a spec asserting metadata lookup uses the aliased package name.

Comment on lines +46 to 48
package_manager: "hex",
metadata: { hex_package: dep["package_name"] }
)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependabot::Dependency#== compares to_h, which includes metadata. By unconditionally setting metadata: { hex_package: dep["package_name"] } for every parsed dependency, you change equality semantics for all Hex dependencies (even non-aliased ones). This will break existing specs in this file that use include(Dependabot::Dependency.new(...)) without matching metadata. Consider only setting :hex_package metadata when the package name differs from dep["name"] (i.e., when an alias is present), or update all existing expectations to include the new metadata field.

Copilot uses AI. Check for mistakes.
@efcasado
Copy link
Copy Markdown
Contributor Author

Curious to hear your thoughts about this change, @robaiken. I see you are usually very active when it comes to changes affecting the Elixir ecosystem 😄

@robaiken robaiken self-assigned this Feb 20, 2026
@robaiken robaiken merged commit f1aa0ad into dependabot:main Feb 20, 2026
54 checks passed
@robaiken
Copy link
Copy Markdown
Contributor

@gabrielfeo Thanks for the contribution. Seems like a usual change for our Elixir users!

@efcasado
Copy link
Copy Markdown
Contributor Author

I can confirm it works as expected (see here). Thanks for the quick turnaround! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: elixir:hex Elixir packages via hex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants