Skip to content

Report unset API Center environment variables - #1985

Open
waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1968-api-center-unset-env
Open

waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1968-api-center-unset-env

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Closes #1968

API Center plugin settings support @NAME to read an environment variable. When the variable wasn't set, the literal @NAME was used, causing an unrelated Azure error later.

Now ApiCenterClient throws ArgumentException (e.g. Environment variable FOO referenced by subscriptionId isn't set.), consistent with the existing config validation. API Center plugins already catch this, log the error, and disable themselves.

Added ApiCenterClientTests covering unset and set variables.

When an API Center setting references an environment variable with
@name and the variable isn't set, throw an error naming the variable
instead of silently using the literal @name value.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 53023532-b4f0-4cd7-a238-b890b15ce83a
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:55
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner October 21, 2026 13:55

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

The focused change uses existing plugin error handling, and no blocking issues were identified; tests were not executed.

No open issues 🎉

What changed in this PR

Reports missing API Center environment variables during initialization instead of allowing misleading Azure errors later.

Changes:

  • Centralizes environment-variable resolution and throws a descriptive ArgumentException for missing or empty values.
  • Adds tests for unset and populated environment variables.
File Description
DevProxy.Plugins/​ApiCenter/​ApiCenterClient.cs Validates environment-variable references across API Center settings.
DevProxy.Integration.Tests/​ApiCenterClientTests.cs Tests missing-variable errors and successful value resolution.

Review effort: Balanced

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

The focused validation change fits existing plugin error handling, with no blocking issues identified; tests were not executed.

No open issues 🎉

Review effort: Balanced

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.

API Center: unset @NAME env var is used as a literal value without warning

2 participants