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

Add trace log message when failing to find Env Var #13777

Merged
merged 7 commits into from
Jun 12, 2024

Conversation

SimonWahlin
Copy link
Collaborator

@SimonWahlin SimonWahlin commented Apr 2, 2024

Fixes #13100

If verbose is set to true in bicepconfig.json, bicep now logs the names of all available environment variables when function readEnvironmentVariable fails to find the variable specified. This should hopefully help troubleshoot errors related to this function.

Example of output before:
image

Example of output after:
image

Contributing a feature

  • I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented
  • I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged
  • I have appropriate test coverage of my new feature
Microsoft Reviewers: Open in CodeFlow

@codecov-commenter
Copy link

codecov-commenter commented Apr 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 7.71%. Comparing base (108d816) to head (7a8fab9).
Report is 1305 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (108d816) and HEAD (7a8fab9). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (108d816) HEAD (7a8fab9)
dotnet 4 0
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #13777       +/-   ##
===========================================
- Coverage   94.28%    7.71%   -86.57%     
===========================================
  Files        1113        7     -1106     
  Lines      100791      350   -100441     
  Branches     8734      127     -8607     
===========================================
- Hits        95028       27    -95001     
+ Misses       4595      322     -4273     
+ Partials     1168        1     -1167     
Flag Coverage Δ
dotnet ?
typescript 7.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1104 files with indirect coverage changes

@SimonWahlin
Copy link
Collaborator Author

@StephenWeatherford I see that one test is failing, but I don't really understand why, don't think it is related to the changes made. Can you help me run it again?

arguments[0].Span,
DiagnosticLevel.Info,
"Bicepparam ReadEnvironmentVariable function",
"Available environment variables are: " + string.Join(", ", model.Environment.GetVariableNames()),
Copy link
Member

Choose a reason for hiding this comment

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

Could this check do something similar to how we handle unknown properties in the type checker? There's a utility method to detect likely typos and include a "did you mean 'x'?" message on

true => SpellChecker.GetSpellingSuggestion(propertyName, availableProperties) switch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a great idea!
I'll look into that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, let me know what you think.

@SimonWahlin SimonWahlin requested review from shenglol and jeskew June 10, 2024 20:37
Copy link
Contributor

@shenglol shenglol left a comment

Choose a reason for hiding this comment

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

:shipit:

@shenglol shenglol merged commit 5f64182 into Azure:main Jun 12, 2024
37 of 39 checks passed
Copy link
Contributor

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add list of environment variables to trace log
5 participants