Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check provider-sourced pattern constraints #16457

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Check provider-sourced pattern constraints #16457

wants to merge 3 commits into from

Conversation

jeskew
Copy link
Member

@jeskew jeskew commented Feb 21, 2025

Resolves #15325

Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

github-actions bot commented Feb 24, 2025

Test this change out locally with the following install scripts (Action run 13509227187)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 13509227187
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 13509227187"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 13509227187
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 13509227187"

Copy link
Contributor

github-actions bot commented Feb 24, 2025

Dotnet Test Results

    78 files   -     39      78 suites   - 39   31m 53s ⏱️ - 15m 32s
11 829 tests  -     11  11 829 ✅  -     11  0 💤 ±0  0 ❌ ±0 
27 416 runs   - 13 697  27 416 ✅  - 13 697  0 💤 ±0  0 ❌ ±0 

Results for commit 214110b. ± Comparison against base commit 3d03ba0.

This pull request removes 1790 and adds 613 tests. Note that renamed tests count towards both.

		nestedProp1: 1
		nestedProp2: 2
		prop1: true
		prop2: false
	1
	2
	\$'")
	prop1: true
	prop2: false
…
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
�ӽ\u000e�0\u0010\u0007��>\u0005OP�J�����+4J�G(\u0006J$1��e0q�� ����˥�k�2��~[�Cٴ�8S�\u0014s��h=z>@B��\u0002\u0002�H	���O2�k�m�(K���T�X���\u0002Y�Ό�LBnr�j\u0013j��\u001a&W�E�.��9ynk74TS
k?4\u001a����Zѧ�\u0003(�����"
�GM!��d������=A\u0014EQ��'� ��\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
�Խ\u000e�0\u0010\u0007��>E�\u0003�\u0016�+������\u0000\u0015Έ\u0011$�	���-�q���ab�c�^�����i�hR�j�t\u0018����[ e�zGHM�~�k�4!�\u001d}�\u001e��1�\u001de��~P\u0010Q�d9�BK.C\u0000\u0005\u000c8@\u0014ɕ�%C5���i�qV�زK}+��|�}�c:\u0003>�7�\u0015}�?\u000f%����B\u0007\u0001���R`�?K&�<�\u000f�\u001d
lKL\u001aLw�\u001f��6�d�5>���q\u001cǙ�\u000bS?:�\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
���\u000b�0\u0014\u0007��+�?`nso��C�!#,\u0008���A\u0006Z���?�<D\u0017��?��9n\u000f���}�۫z�U��\u0012����Q߈!8o]oP.\u0011�o\u0004\u0011	 \u0011r��;i�(+U�V�8�\u0007����4�!��p_\u0008\u0010\u0018�\u0004\u0002���޹k�\u0006�]U�0�\u0013]�ky˛�|�kZ\u001d>�7�\u0013}�?a\u001c�\u0019\u0000�JƄɿ\u0000\u0000��Q2�����Q|\n��is����1\u0013x�,˲��\u0000B��r\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003�ӽ\u000e�0\u0010\u0007��>\u0005OP��\u001eg\u0007vG_�Q\u0012?B1\u0002������\u0001�`b�c������t�M��ŵ�\u001aئRL
�̘��\u001e\u0012
�\u0017\u0010�D�v�M�ɀ�n�5�2Ǭ\u001f�։k�e�#\u001b0:# i	�U�
��h
��k\u000ey�Ͼ�yy�+�7�c
K?4\u001a���ߚ�)�\u0000J�abd\u0005\u001aC�QS��,�����\u001fKo\u0010EQ\u0014-�	\u0015\u000eK�\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003�Խ
�0\u0010\u0007��>E�\u0003��6\u001fV� 8X�*\u0008�\u0012l�
��V(�\uda58\udcf8���C0�19�\u000b���ݫz�U���� \u0003����!\u0018k=oP&\u0011�o�@rA\u0011�ux��*�(c��A�\u001c�*�tH%\u0003�\u000b\u000e�\u0004�\u0007A��ܝ��h�諸�i��\�[ޔg]�S?������z|�?x\u000c�\u001d�%�\u001e�\u0014����(����?�(>.���9�bg��\u0006�z&˲,kx/硖W\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003��K
�0\u0010\u0006�=E�\u0001�ͣ\u0015�w#��\u0000�\u001d�bki+\u0014Ļ�.�M��>\u0004�-3\u00033!�a�i�hR�j\u0016��֌�
,%D�y�\u000bM�~\u0003\u0002Z*N\u0008mGߤǽnLeW�c�\u000f�Cj�,ǘk\u0001"P\u0012$�B�|%W��\u000c�xDKӜ�H�e��Vt��P���t\u0006|�o�\u0019��\u000f� �\u000f��k\u001f\u0002N@I���ϒ�?���z�\u0002�\u0012�\u0006�\u001d�G��
=�k�ϥws\u001c�q��\u0002�L�A\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.DecompilationTests ‑ Decompiler_handles_banned_function_replacement ("createArray(1, 2, 3)","array","[
  1
  2
  3
]")
Bicep.Core.IntegrationTests.DecompilationTests ‑ Decompiler_handles_banned_function_replacement ("createObject('key', 'value')","object","{
  key: 'value'
}")
Bicep.Core.IntegrationTests.DecompilationTests ‑ Decompiler_handles_strings_with_newlines ("
","\n")
Bicep.Core.IntegrationTests.DecompilationTests ‑ Decompiler_handles_strings_with_newlines ("
","\r\n")
…

♻️ This comment has been updated with latest results.

# Conflicts:
#	src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Comment on lines +120 to +122
// using RegexOptions.ECMAScript for Swagger compatibility. Because this option is
// incompatible with .NET's non-backtracking engine, a timeout is used.
? new Regex(@string.Pattern, RegexOptions.ECMAScript, TimeSpan.FromMilliseconds(100))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if we should be special-casing patterns that come from the az provider. The behavioral differences between standard regexes and the ECMAScript dialect are subtle [0], and I would be surprised if Azure RPs are using the ECMAScript dialect in practice.

Needing to track whether a pattern came from the Az provider types (and thus needs to be interpreted per the ECMAScript dialect) or not (and therefore needs to be interpreted with the standard dialect and non-backtracking engine) adds a fair amount of complexity.

[0]: These would be:

  • \w doesn't match alphabetic characters in languages that use non-Latin alphabets
  • self-referencing capture groups are supported
  • the \ means slightly different things when it's not referring to a capture group

Cf https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options#ecmascript-matching-behavior

@jeskew jeskew marked this pull request as ready for review February 24, 2025 22:54
@jeskew jeskew requested a review from a team February 24, 2025 22:54
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.

Consume the pattern property in swagger specs during Bicep type generation to enable better regex validation
1 participant