azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Azure Monitor Exporter connection string parser insights key validator regex expression

Open tomasro27 opened this issue 2 years ago • 3 comments

  • azure-monitor-opentelemetry-exporter
  • 1.0.0b4
  • linux/ubuntu
  • 3.8

Describe the bug ValueError: Invalid instrumentation key. It should be a valid UUID.

The regex validation in _connection_string_parser.py for azure monitor exporter seems wrong. This is being used: uuid_regex_pattern = re.compile( "^[0-9a-f]{8}-" "[0-9a-f]{4}-" "[1-5][0-9a-f]{3}-" "[89ab][0-9a-f]{3}-" "[0-9a-f]{12}$" ) But app insights has generated a key where the first letter is not [1-5]. How is this regex not [0-9a-f] for all of the segments of the uuid?

uuid_regex_pattern = re.compile( "^[0-9a-f]{8}-" "[0-9a-f]{4}-" "[0-9a-f]{4}-" "[0-9a-f]{4}-" "[0-9a-f]{12}$" )

To Reproduce Steps to reproduce the behavior: 1. connection_string = 'aa11a1aa-aaa1-f111-aa1a-11111aa11a11' AzureMonitorTraceExporter.from_connection_string(connection_string)

throws ValueError: Invalid instrumentation key. It should be a valid UUID. Expected behavior A clear and concise description of what you expected to happen.

This code should work?

tomasro27 avatar Dec 11 '22 03:12 tomasro27

Thank you for your feedback @tomasro27. We will investigate asap and get back to you

kashifkhan avatar Dec 12 '22 15:12 kashifkhan

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Dec 12 '22 15:12 ghost

@tomasro27

But app insights has generated a key where the first letter is not [1-5].

You were able to generate an ikey in which the first character of the third section was not in [1-5] for Application Insights in production?

lzchen avatar Jan 03 '23 21:01 lzchen

Fixed with https://github.com/Azure/azure-sdk-for-python/pull/28316

lzchen avatar Jan 12 '23 22:01 lzchen