Repository navigation
Test-AdfLinkedService: count failures instead of stopping, accept array of names #382 - #517
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #382
Root cause
Invoke-AzRestMethoddoes not throw on HTTP errors, so an error response ({"error": {...}}, e.g. linked service not found) reachedTest-AdfLinkedServicewithout asucceededproperty. Reading$r.succeededthen threwPropertyNotFoundunder the module'sSet-StrictMode -Version Latest, whatever the caller's strict mode was.'LS1, LS2'tested' LS2', which doesn't exist, so every name after the first one hit the error above.-LinkedServiceNamewas[String], so an array ('LS1', 'LS2') could not be bound.Invoke-AzRestMethodcall, and a json definition entry withoutparametersalso stopped the whole run.Changes
-LinkedServiceNameis[String[]]: an array of names, a comma-separated list (names are trimmed, empty items skipped) or a json definition file, as before.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.Errorsentry (same keys asReport) with the API error message of each failed test, also printed in the log. Previously it was only in verbose output.parametersproperty (previously a strict-mode error).Compatibility with the azure.datafactory.devops extension
The Test Linked Service task (V1 and V2) calls
Test-AdfLinkedService -LinkedServiceName $LinkedServiceNamewith 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 failedwith 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 inps_modules, so the fix reaches it only when the extension is rebuilt with the new module version.Tests
test/Test-AdfLinkedService.Tests.ps1: error response, error message fromerrors/error, trimming, array, empty items, the extension's single-string call, json definition withoutparameters, Service Principal failure and missing linked service, andInvoke-AzRestMethodHTTP error and exception. Each one failed before the fix.generic) pass under bothStopandContinue.🤖 Generated with Claude Code