bazelbuild / bazelbuild/rules_license

Avoid duplicate packages

Open
#112 0 comments 0 reactions 0 assignees View on GitHub
bug P2
Dominant language
Starlark
Stars
85
Forks
37
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior

When running `bazel build //examples/sboms:write_sbom_sbom`, the resulting JSON should look as follows:

```json
[
{
"top_level_target": "//tools:write_sbom",
"dependencies": [
{
"target_under_license": "//tools:write_sbom",
"licenses": [
"//:license"
]
}
],
"licenses": [
{
"label": "//:license",
"bazel_package": "//",
"license_kinds": [
{
"target": "@//licenses/spdx:Apache-2.0",
"name": "Apache-2.0",
"conditions": []
}
],
"copyright_notice": "",
"package_name": "rules_license",
"package_url": "",
"package_version": "0.0.7",
"license_text": "LICENSE",
"used_by": [
"//tools:write_sbom"
]
}
],
"packages": [
{
"target": "//:package_info",
"bazel_package": "//",
"package_name": "rules_license",
"package_url": "",
"package_version": "0.0.7"
}
]
}
]
```

## Actual Behavior

When running `bazel build //examples/sboms:write_sbom_sbom`, the resulting JSON actually looks as follows:

```json
[
{
"top_level_target": "//tools:write_sbom",
"dependencies": [
{
"target_under_license": "//tools:write_sbom",
"licenses": [
"//:license"
]
}
],
"licenses": [
{
"label": "//:license",
"bazel_package": "//",
"license_kinds": [
{
"target": "@//licenses/spdx:Apache-2.0",
"name": "Apache-2.0",
"conditions": []
}
],
"copyright_notice": "",
"package_name": "",
"package_url": "",
"package_version": "",
"license_text": "LICENSE",
"used_by": [
"//tools:write_sbom"
]
}
],
"packages": [
{
"target": "//:package_info",
"bazel_package": "//",
"package_name": "rules_license",
"package_url": "",
"package_version": "0.0.7"
},
{
"target": "//:package_info",
"bazel_package": "//",
"package_name": "rules_license",
"package_url": "",
"package_version": "0.0.7"
}
]
}
]
```

Specifically, the same package is included twice and the license doesn't contain `package_name` and `package_version` fields.

## Steps to Reproduce the Problem

1. Run `bazel build //examples/sboms:write_sbom_sbom`
1. Inspect `bazel-bin/examples/sboms/_write_sbom_sbom_licenses_info.json`

## Specifications

- Version:
- Platform:

Contributor guide

Open the contributing guide

Research direction

Run `bazel build //examples/sboms:write_sbom_sbom` and inspect `bazel-bin/examples/sboms/_write_sbom_sbom_licenses_info.json`. Trace the SBOM generation from that output to identify why `//:package_info` is emitted twice and why package metadata is absent from the license. Done means the generated JSON matches the expected single package entry and populated fields.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.