Azure / Azure/azure-powershell

[Feature]: Start-AzVirtualNetworkGatewayConnectionPacketCapture should validate JSON for filterdata parameter

Open
#30,088 1 comment 0 reactions 0 assignees View on GitHub
customer-reported feature-request Network - Virtual Network Network - VPN Gateway Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description of the new feature

There currently does not seem to be validation for the `FilterData` parameter, which means that when stopping the packet capture we only see an error `ErrorCode: NoPacketCaptureResponseDataFound`.

It would be helpful to validate the expected JSON string or to use a proper class so that type casting could be used instead.

Example with wrong filter

```powershell
# Filter should have rather been: $filterdata = @{Filters = @(@{DestinationSubnets = @('10.0.0.0/16')})} | ConvertTo-Json -Compress -Depth 3
$filterdata = @{DestinationSubnets = @('10.0.0.0/16')} | ConvertTo-Json -Compress
Start-AzVirtualNetworkGatewayConnectionPacketCapture -ResourceGroupName some-rg -Name some-connection -FilterData $filterdata

```

The command is accepted despite the wrong filter and the trace is started, but when stopping:

```output
Stop-AzVirtualNetworkGatewayConnectionPacketCapture: Long running operation failed with status 'Failed'. Additional Info:'An internal error occured. The response did not contain any data. Please check storage for the capture.'
StatusCode: 200
ReasonPhrase: OK
Status: Failed
ErrorCode: NoPacketCaptureResponseDataFound
ErrorMessage: An internal error occured. The response did not contain any data. Please check storage for the capture.
```

### Proposed implementation details (optional)

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the implementation of Start-AzVirtualNetworkGatewayConnectionPacketCapture and trace how the FilterData parameter is handled. Compare the documented Filters/DestinationSubnets JSON shape with the incorrect example, then inspect nearby command tests if available. Done means invalid filter data is rejected before capture starts and valid filter data continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.