Skip to content

fix: Short-circuit adapter discovery when a native resource type has no matching version#1532

Open
Gijsreyn wants to merge 4 commits into
PowerShell:mainfrom
Gijsreyn:gh-1531/main/fix-discovery-requireversion
Open

fix: Short-circuit adapter discovery when a native resource type has no matching version#1532
Gijsreyn wants to merge 4 commits into
PowerShell:mainfrom
Gijsreyn:gh-1531/main/fix-discovery-requireversion

Conversation

@Gijsreyn
Copy link
Copy Markdown
Collaborator

PR Summary

This pull request makes discovery fail fast in a scenario when a configuration document pins a resource with requireVersion, and the requested type is a known native command-based DSC resource, but no installed version satisfies the requirement.

When a user adds the requireAdapter in the configuration document, a sweep still runs, so that behavior is unchanged. It is mainly on native type + version mismatch + no requireAdapter.

PR Context

Fixes #1531

@Gijsreyn Gijsreyn marked this pull request as ready for review May 14, 2026 17:59
Copilot AI review requested due to automatic review settings May 14, 2026 17:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Optimizes command-based resource discovery by avoiding adapter enumeration in cases where remaining unsatisfied filters correspond to natively-registered resource types (and no adapter is explicitly required), and adds trace logging + test coverage for the new behavior.

Changes:

  • Add pre-filtering step to only perform adapter discovery for filters that actually require it.
  • Add a trace message when adapter discovery is skipped for a natively-registered type due to version mismatch.
  • Add a PowerShell test ensuring adapter discovery is skipped in the native-type version mismatch case.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/dsc-lib/src/discovery/command_discovery.rs Introduces adapter candidate filtering and early-return to skip adapter discovery in native-type mismatch scenarios.
lib/dsc-lib/locales/en-us.toml Adds localized trace message for the adapter-skip scenario.
dsc/tests/dsc_config_version.tests.ps1 Adds regression test asserting adapter discovery is not invoked when native type version constraints can’t be met.

Comment thread lib/dsc-lib/src/discovery/command_discovery.rs
Comment thread lib/dsc-lib/src/discovery/command_discovery.rs
Comment thread lib/dsc-lib/locales/en-us.toml Outdated
@Gijsreyn Gijsreyn force-pushed the gh-1531/main/fix-discovery-requireversion branch from a6345ce to ab4ab4e Compare May 15, 2026 04:46
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.

Discovery falls through to adapters when requireVersion doesn't match a native resource

2 participants