Skip to content

[2.x] fix: Relax non-delegation for settings on shell#8751

Merged
eed3si9n merged 3 commits intosbt:developfrom
bitloi:feature/2050-resolve-key
Feb 18, 2026
Merged

[2.x] fix: Relax non-delegation for settings on shell#8751
eed3si9n merged 3 commits intosbt:developfrom
bitloi:feature/2050-resolve-key

Conversation

@bitloi
Copy link
Copy Markdown
Contributor

@bitloi bitloi commented Feb 17, 2026

Fixes #8757

Problem

After the change in #8539, the shell stopped delegating for any scoped key. So when you run something like Compile/console/fork, you get "No such setting/task" even when console/fork is defined in a delegated scope (e.g. the default config). That’s annoying for settings, where delegation is usually what you want.

Solution

We keep the current behaviour for tasks: if you type a task with an explicit scope and it isn’t defined in that exact scope, it still fails (so typos like Compile/update don’t silently run something else). For settings we allow delegation again: if the key isn’t found in the requested scope, we follow the normal scope delegation and use the value from a delegate scope. So Compile/console/fork works when console/fork is defined in a more general scope.

The change is in Act.getValue: when the user has specified an explicit config or task scope we still try a direct lookup first; if that returns nothing and the key is a setting (via key.key.tag.isSetting), we fall back to data.get(key) so delegation applies. Task keys never use that fallback.

Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

afaik #2050 is already a done issue.

@bitloi bitloi force-pushed the feature/2050-resolve-key branch from a2abdc1 to cc88f1b Compare February 17, 2026 13:22
@bitloi bitloi changed the title feat: provide method to transform keys to scoped keys feat: operation-based incremental cache for plugins Feb 17, 2026
@bitloi bitloi requested a review from eed3si9n February 17, 2026 13:27
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

I don't think this feature is needed in sbt 2.x since we already implement caching for tasks by default.

Allow settings to delegate when the user specifies an explicit scope
(config or task axis), so that e.g. Compile/console/fork resolves
when console/fork is defined in a delegated scope. Tasks continue to
not delegate (getDirect only) so non-existent scopes like Compile/update
still fail as in 2.0.0.
@bitloi bitloi force-pushed the feature/2050-resolve-key branch from 7d905ba to 0479d71 Compare February 17, 2026 19:37
@bitloi bitloi changed the title feat: operation-based incremental cache for plugins fix: Relax non-delegation for settings on shell Feb 17, 2026
@bitloi bitloi requested a review from eed3si9n February 17, 2026 19:42
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Could you add a scripted test for this please?

@bitloi
Copy link
Copy Markdown
Contributor Author

bitloi commented Feb 18, 2026

Could you add a scripted test for this please?

I added it. Would you mind reviewing it again?

@eed3si9n eed3si9n changed the title fix: Relax non-delegation for settings on shell [2.x] fix: Relax non-delegation for settings on shell Feb 18, 2026
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@eed3si9n eed3si9n merged commit b634e1b into sbt:develop Feb 18, 2026
15 checks passed
EndlessLucky pushed a commit to EndlessLucky/sbt that referenced this pull request Mar 27, 2026
Allow settings to delegate when the user specifies an explicit scope
(config or task axis), so that e.g. Compile/console/fork resolves
when console/fork is defined in a delegated scope. Tasks continue to
not delegate (getDirect only) so non-existent scopes like Compile/update
still fail as in 2.0.0.
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.x] Relax non-delegation for settings

2 participants