Skip to content

Limit configuration sources to project-local settings - #21679

Merged
James Newton-King (JamesNK) merged 3 commits into
mainfrom
jamesnk/project-local-config-sources
Nov 2, 2026
Merged

James Newton-King (JamesNK) merged 3 commits into
mainfrom
jamesnk/project-local-config-sources

Conversation

@JamesNK

Copy link
Copy Markdown
Member

Description

Configuration sources belong to projects, but the CLI currently also checks and refreshes configSource bindings found in global configuration. This can cause unexpected Git access and changes to global settings. Ignore global bindings so adding one has no effect.

  • Check and refresh only the binding in the selected project's nearest local configuration file.
  • Ignore valid, invalid, and unavailable global bindings without source acquisition, advisory warnings, or global configuration changes.
  • Preserve nearest-file discovery, unrelated settings, local source refresh, and shared-cache freshness across different projects.
  • Remove the global-configuration dependency and multi-binding processing from ConfigSourceService.
  • Store one nullable comparedAppliedVersion in check metadata instead of an array. Older metadata is revalidated once when its observation does not match the project's applied version.
  • Update command help, generated localization, documentation, and regression tests.

Other global settings, including named templateSources, retain their existing behavior.

User-facing usage

Keep the source binding in the project's aspire.config.json, then refresh it with:

aspire update --config-source --yes --non-interactive

Only the nearest local binding is refreshed. If only global configuration contains a binding, this command succeeds with the existing no-source notice and performs no Git acquisition or configuration writes.

Relevant generated help:

Usage:
  aspire update [options]

Options:
  --config-source  Apply allowed settings from the nearest local saved Git configuration source, replacing local edits to supplied settings, without updating packages or the CLI.

Validation

Final config-source service and command regression tests: passed, 221 succeeded, 0 failed, 0 skipped.

$env:MSBUILDTERMINALLOGGER='false'
dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.ConfigSourceServiceTests" --filter-class "*.ConfigSourceCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Localization regeneration: passed, 0 warnings and 0 errors.

dotnet build src\Aspire.Cli\Aspire.Cli.csproj /t:UpdateXlf

Committed diff whitespace validation: passed.

git diff --check main...jamesnk/project-local-config-sources

The full repository suite was not run.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21679

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21679"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests use a global fixture disconnected from the service, leaving advisory checks and forced refresh without coverage that would catch reintroduced processing of the real global settings file.

1 open issue
1 file not reviewed
  • src/Aspire.Cli/Resources/ConfigSourceStrings.Designer.cs: Generated file
What changed in this PR

This PR limits Aspire CLI configuration-source checks and refreshes to the selected project's nearest local configuration file, preventing global bindings from triggering Git access or configuration changes.

Changes:

  • Removes global-binding discovery and multi-binding processing from ConfigSourceService.
  • Simplifies shared check metadata to one nullable applied version, with legacy metadata revalidation.
  • Updates regression tests, command help, generated localization resources, and specifications.
File Description
tests/​Aspire.Cli.Tests/​TestServices/​TestConfigSourceServices.cs Removes global-settings injection from the service helper.
tests/​Aspire.Cli.Tests/​Configuration/​ConfigSourceServiceTests.cs Revises local-only, shared-cache, and legacy-metadata tests.
tests/​Aspire.Cli.Tests/​Commands/​ConfigSourceCommandTests.cs Verifies explicit refresh ignores a global binding.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.zh-Hant.xlf Updates generated Traditional Chinese help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.zh-Hans.xlf Updates generated Simplified Chinese help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.tr.xlf Updates generated Turkish help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.ru.xlf Updates generated Russian help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.pt-BR.xlf Updates generated Brazilian Portuguese help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.pl.xlf Updates generated Polish help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.ko.xlf Updates generated Korean help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.ja.xlf Updates generated Japanese help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.it.xlf Updates generated Italian help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.fr.xlf Updates generated French help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.es.xlf Updates generated Spanish help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.de.xlf Updates generated German help resource.
src/​Aspire.Cli/​Resources/​xlf/​ConfigSourceStrings.cs.xlf Updates generated Czech help resource.
src/​Aspire.Cli/​Resources/​ConfigSourceStrings.resx Describes refresh as nearest-local only.
src/​Aspire.Cli/​Resources/​ConfigSourceStrings.Designer.cs Aligns the resource accessor's documentation with the help text.
src/​Aspire.Cli/​Configuration/​ConfigSourceService.cs Processes only the nearest local binding and simplifies cache comparisons.
src/​Aspire.Cli/​Configuration/​ConfigSource.cs Replaces the compared-version array with a nullable string.
docs/​specs/​cli-config-sources.md Documents local-only behavior and revised coverage requirements.
docs/​specs/​cli-config-sources-1p-scenarios.md Clarifies that global bindings have no effect.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the project-local configuration-source changes.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • src/Aspire.Cli/Resources/ConfigSourceStrings.Designer.cs: Generated file

Review effort: Balanced

Preserve project-local-only configuration-source checks alongside adoption and explicit project opt-outs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Tests selector

3 / 100 PR test projects · 4 PR jobs, from 20 changed files.

Selected PR test projects (3 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Infrastructure.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Cli/Resources/ConfigSourceStrings.resx (changed source)
→ 1 directly: Infrastructure.Tests

🧪 tests/Aspire.Cli.Tests/Commands/ConfigSourceCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Configuration/ConfigSourceServiceTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/TestConfigSourceServices.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Configuration/ConfigSource.cs, src/Aspire.Cli/Configuration/ConfigSourceService.cs, src/Aspire.Cli/Resources/ConfigSourceStrings.Designer.cs, src/Aspire.Cli/Resources/ConfigSourceStrings.resx, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.de.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.es.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.it.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/ConfigSourceStrings.zh-Hant.xlf
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit a1626b5.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the changes limiting configuration-source processing to the nearest local configuration file.

No open issues 🎉

1 file not reviewed
  • src/Aspire.Cli/Resources/ConfigSourceStrings.Designer.cs: Generated file

Review effort: Balanced

@JamesNK
James Newton-King (JamesNK) merged commit 1afc0d0 into main Nov 2, 2026
216 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 2, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2025

Generated by PR Documentation Check · copilot · auto · 28.8 AIC · ⌖ 1.13 AIC · ⊞ 7.1K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2025 targeting release/17.0.

Documented aspire update --config-source (project-local config sources only; global bindings ignored) in aspire-update.mdx. Signals: cli_resource_strings_changed (ConfigSourceStrings.resx), pr_body_has_cli_flag_mention (--config-source), pr_body_has_user_facing_section ("User-facing usage").

Note

This draft PR needs human review before merging.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants