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

Fixes bug in dimensions property for metric & log alerts generation for Bicep templates #503

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

feliasson
Copy link

@feliasson feliasson commented Jan 23, 2025

Overview/Summary

Fixes #505

This PR fixes/adds/changes/removes

  • Fixes a bug in generate-templates.py and the related bicep base templates that is used for generating bicep metricAlerts & scheduledQueryRules templates that had the dimensions property being populated with an empty array inside already empty array dimensions: [[]].

    • For VS Code Bicep Extension this gives the warning The enclosing array expected an item of type "MetricDimension", but the provided item was of type "<empty array>".bicep[BCP034](https://aka.ms/bicep/core-diagnostics#BCP034)

    image

    • When trying to deploy the Bicep templates with this occurance you are met with the following error:
    "statusMessage": "{\"error\":{\"code\":\"InvalidTemplateDeployment\",\"message\":\"The template deployment '-20250123-122657' is not valid according to the validation procedure. The tracking id is '008e3888-6da0-4861-a9d9-06300c1630b8'. See inner errors for details.\",\"details\":[{\"code\":\"BadRequest\",\"target\":\"/subscriptions/<obfuscated>/resourceGroups/rg-amba-monitoring-sdc-testing/providers/Microsoft.Insights/metricAlerts/AvailableMemoryBytes\",\"message\":\"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'AlertRP.Models.MetricAlerts.v20180301.MetricDimension' because the type requires a JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) to deserialize correctly.\\r\\nTo fix this error either change the JSON to a JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\\r\\nPath 'dimensions[0]'.\"}]}}",
    

Testing the fix

  • I have tested the fix and ran the generate-templates.py from a branch from my fork which can be found here: feliasson@7999ff4 (I assume they should be updated by your regular CI/CD processes instead of in this PR)
  • I have tested deploying all of the metricAlerts & scheduledQueryRules Bicep templates after the fix from my fork

As part of this Pull Request I have

  • Read the Contribution Guide and ensured this PR is compliant with the guide
  • Checked for duplicate Pull Requests
  • Associated it with relevant GitHub Issues or ADO Work Items (Internal Only)
  • Ensured my code/branch is up-to-date with the latest changes in the main branch
  • Ensured PR tests are passing
  • Updated relevant and associated documentation (e.g. Contribution Guide, Docs etc.)

@feliasson feliasson marked this pull request as ready for review January 23, 2025 14:22
@feliasson feliasson requested a review from a team as a code owner January 23, 2025 14:22
@judyer28
Copy link
Collaborator

@feliasson thanks for your interest in AMBA. Please submit a bug under issues and we will have a look at fixing this in an upcoming release.

@feliasson
Copy link
Author

@judyer28 - I have created #505 for this, if possible please add to the Contributing section of the README.md that this is expected for Pull Requests.

@Brunoga-MS Brunoga-MS added the AMBA Core Issues / PR's related AMBA Core label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AMBA Core Issues / PR's related AMBA Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[General workload issue]: Bug in dimensions property for metric & log alerts generation for Bicep templates
3 participants