Skip to content

fix: handle missing 'path' key in dependency resolution#70

Closed
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
rejuvenile:fix-missing-path-key-in-dep-resolution
Closed

fix: handle missing 'path' key in dependency resolution#70
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
rejuvenile:fix-missing-path-key-in-dep-resolution

Conversation

@rejuvenile
Copy link
Copy Markdown
Contributor

Summary

Registry deps in workspace package dependency lists may lack a path key — they only have source. The extension code in _generate_hub_and_spokes assumed all deps without a bazel_target have a path, causing KeyError when processing workspace packages that include registry dependencies.

Problem

When a workspace Cargo.toml has dependencies on both local path crates and registry crates (from crates.io), cargo metadata output for the workspace package includes both types in its dependencies list. Registry deps only have source (e.g., registry+https://github.com/rust-lang/crates.io-index) but no path key. The current code does:

bazel_target = "//" + paths.join(workspace_package, _normalize_path(dep["path"]).removeprefix(repo_root + "/"))

This crashes with KeyError on registry deps because dep["path"] doesn't exist.

Fix

Check for the path key with dep.get("path") before using it. If the dep has no path, skip it with continue since registry crates are already handled via the crate hub mechanism.

Changes

  • rs/extensions.bzl: Guard against missing path key in workspace package dependency iteration

Registry deps in workspace package dependency lists may lack a `path`
key — they only have `source`. The extension assumed all deps without
a bazel_target have a path, causing KeyError when processing workspace
packages that include registry dependencies.

Skip these deps since they're handled via the crate hub.
@dzbarsky
Copy link
Copy Markdown
Member

@rejuvenile I'm not sure I understand the scenario you hit, could you possibly add an e2e smoke test to test/ following the existing examples? (codex/claude should be able to do it easily). That will help me understand and prevent future regression :)

@longlho
Copy link
Copy Markdown
Contributor

longlho commented Apr 14, 2026

#90 fixes the same thing with test I believe

@dzbarsky
Copy link
Copy Markdown
Member

@rejuvenile please let us know if you're still seeing issues after Long's fix!

@dzbarsky dzbarsky closed this Apr 14, 2026
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.

3 participants