Skip to content

Test-AdfLinkedService: count failures instead of stopping, accept array of names #382 - #517

Merged
NowinskiK merged 1 commit into
developfrom
issue-382-test-linkedservice
Oct 17, 2026
Merged

NowinskiK merged 1 commit into
developfrom
issue-382-test-linkedservice

Conversation

@NowinskiK

Copy link
Copy Markdown
Member

Closes #382

Root cause

  • Invoke-AzRestMethod does not throw on HTTP errors, so an error response ({"error": {...}}, e.g. linked service not found) reached Test-AdfLinkedService without a succeeded property. Reading $r.succeeded then threw PropertyNotFound under the module's Set-StrictMode -Version Latest, whatever the caller's strict mode was.
  • A comma-separated list was split without trimming: 'LS1, LS2' tested ' LS2', which doesn't exist, so every name after the first one hit the error above.
  • -LinkedServiceName was [String], so an array ('LS1', 'LS2') could not be bound.
  • Found while testing: a missing linked service with Service Principal auth, a failed Invoke-AzRestMethod call, and a json definition entry without parameters also stopped the whole run.

Changes

  • -LinkedServiceName is [String[]]: an array of names, a comma-separated list (names are trimmed, empty items skipped) or a json definition file, as before.
  • A response without succeeded = $true, a missing linked service or a failed API call counts as a failed test of that linked service, and the other linked services are still tested. This holds with $ErrorActionPreference = 'Stop' too.
  • The result has a new Errors entry (same keys as Report) with the API error message of each failed test, also printed in the log. Previously it was only in verbose output.
  • Parameters from a json definition file are added to linked services that have no parameters property (previously a strict-mode error).

Compatibility with the azure.datafactory.devops extension

The Test Linked Service task (V1 and V2) calls Test-AdfLinkedService -LinkedServiceName $LinkedServiceName with a single [string]: a comma-separated list or a json file path from the task input. A [String[]] parameter binds a single string as a one-element array, and that element is processed exactly as before. A test covers this call. No change is needed in the extension.

One difference in behaviour: a task run that used to crash on an error response (e.g. a misspelled linked service name) now finishes and logs Connection failed with the reason. A failed connection test (succeeded: false) has always behaved like that, because the task discards the result ($null = Test-AdfLinkedService ...). If the task should fail when any test fails, that's a follow-up in the extension: check $r.Failed -gt 0. The extension bundles the module in ps_modules, so the fix reaches it only when the extension is rebuilt with the new module version.

Tests

  • 11 new unit tests in test/Test-AdfLinkedService.Tests.ps1: error response, error message from errors/error, trimming, array, empty items, the extension's single-string call, json definition without parameters, Service Principal failure and missing linked service, and Invoke-AzRestMethod HTTP error and exception. Each one failed before the fix.
  • All 25 tests (with generic) pass under both Stop and Continue.

🤖 Generated with Claude Code

…ay of names #382

- An error response (no 'succeeded'), a missing linked service or a failed
  API call is a failed test with the API message in the new Errors result,
  instead of PropertyNotFound under the module's strict mode
- LinkedServiceName is [String[]]: an array, a comma-separated list (names
  are trimmed, empty items skipped) or a json definition file
- Parameters are added to linked services without 'parameters' property

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NowinskiK
NowinskiK merged commit e081f02 into develop Oct 17, 2026
2 checks passed
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.

1 participant