incompatible_disable_target_default_provider_fields: Disallow use of default providers for legacy "struct access"
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
https://bazel.build/extending/rules#migrating_from_legacy_providers describes that using "struct access" patterns is already a legacy approach, and the preferred "modern" approach is to use explicit providers. That is
```
ctx.atr.foo.default_runfiles
```
should instead become
```
ctx.attr.foo[DefaultInfo].default_runfiles
```
Addressing the default provider directly by strings - e.g., `ctx.attr.foo.data_runfiles` - has the potential for namespace clash. This has happened in the past. That is, `ctx.attr.foo.fieldname` can potentially return a provider rather than a data field. However, `ctx.attr.foo[fieldname]` will always return a provider.
Contributor guide
Research direction
Begin with the linked Bazel migration guidance and compare the legacy struct-access examples with explicit provider access. Identify the Bazel validation and tests governing these two access forms; done means legacy string-based default-provider access is rejected while bracketed explicit-provider access remains supported.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100