Skip to content

Bug fix for Set-PSResourceRepository dynamic parameter - #2067

Open
alerickson wants to merge 2 commits into
masterfrom
setPSGallery
Open

alerickson wants to merge 2 commits into
masterfrom
setPSGallery

Conversation

@alerickson

Copy link
Copy Markdown
Member

PR Summary

This PR moves CheckRepositoryStore() from BeginProcessing() to the start of GetDynamicParameters() because PowerShell calls them in this order:

  • GetDynamicParameters()
  • BeginProcessing()
  • ProcessRecord()

Previously, dynamic parameter discovery tried to read the repository store before it had been created. On a fresh installation, that threw an exception, so execution never reached the initialization in BeginProcessing().

Initializing immediately before the read fixes that ordering problem using the existing initialization logic. The old BeginProcessing() override was removed because it would only repeat the same check.

PR Context

Resolves issue #2066

PR Checklist

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@alerickson

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The missing-store scenario needs an automated regression test because existing tests pre-create the store.

1 open finding
What changed in this PR

Fixes the fresh-install failure reported in #2066 by initializing the repository store before dynamic parameter discovery reads it.

Changes:

  • Moves CheckRepositoryStore() into GetDynamicParameters().
  • Removes the redundant BeginProcessing() override.
File Description
src/​code/​SetPSResourceRepository.cs Initializes the repository store before dynamic parameter discovery.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/code/SetPSResourceRepository.cs
@alerickson

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

This branch has not been deployed

No deployments
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 participants