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

CreateUiDefinition - NestedTemplates - Outputs Must Be Present In Template Parameters - Requires un-needed parameters #492

Closed
stephenpope opened this issue Aug 9, 2021 · 6 comments · Fixed by #543
Assignees
Labels
bug Something isn't working
Milestone

Comments

@stephenpope
Copy link

As there are a few files involved i have created a Gist to help out -> https://gist.github.com/stephenpope/790a88595efa698e70cd73c31e476084

Setup

I have a simple bicep structure a main file with two modules (that create nested templates) ..

main.bicep
  another.bicep
  yetanother.bicep

these can be built into a azuredeploy.json with bicep build main.bicep --output azuredeploy.json

There is also createUiDefinition.json .. this has two textboxes which have outputs defined as oneParameter + twoParameter to match the input params of the azuredeploy script.

Error

The script shows errors even though oneParameter and twoParameter are defined in the main.bicep file (and appear in the main parameters section in the json).

//filename: main.bicep
param oneParameter string = 'defaultValue'
param twoParameter string = 'anotherValue'
//<snip>
NestedTemplate my-thing my-thing my-other-thing my-other-thing [ Lines 44 - 74 ]
  [-] Outputs Must Be Present In Template Parameters (21 ms)
      output oneParameter does not exist in template.parameters
      output twoParameter does not exist in template.parameters
      output oneParameter does not exist in template.parameters
      output twoParameter does not exist in template.parameters

Discussion

These parameters are not defined in the nested modules because they are not needed. The nested modules have their own parameters.

This seems like an error in working out the constraints (unless I am mistaken :)

@ghost ghost added the Needs: triage 🔍 label Aug 9, 2021
@bmoore-msft bmoore-msft added bug Something isn't working and removed Needs: triage 🔍 labels Aug 23, 2021
@Iphone36
Copy link

@bmoore-msft

@StartAutomating
Copy link
Collaborator

👍 looks like we need to track if we're testing a nested template or not.

@bmoore-msft bmoore-msft added this to the M3 milestone Sep 10, 2021
@StartAutomating
Copy link
Collaborator

It looks like the current PR #535 touches on the same case.

If a test has parameters that indicate it was a maintemplateobject, those parameters should be cleared. If any of them were required, the test should be skipped (quietly).

e.g. if there was a test requring MainTemplateObject, it should not run when evaulating inner templates of the mainTemplateObject.

Skipping of tests can be indicated with Write-Verbose, but would be too noisy otherwise.

@StartAutomating
Copy link
Collaborator

We should back out some of the changes to $TemplateObject if #535 is merged, once a fix for this bug is available.

@stephenpope
Copy link
Author

stephenpope commented Nov 15, 2021

I have noticed with the latest version (2021.11.05) it thinks secure param values are required in nestedTemplates. So if I have a nested template (module in bicep) with..

@secure()
@description('Specifies the SSH RSA public key string for the Linux nodes.')
param aksClusterSshPublicKey string

.. results in ..

NestedTemplate ...
    [-] Parameters Without Default Must Exist In CreateUIDefinition (80 ms)                                                 
        aksClusterSshPublicKey does not have a default value, and is not defined in CreateUIDefinition.outuputs  

.. but obviously putting a default value in a secure valueis not allowed.

For clarification: The param in this case does not have its value filled by the UI but by a separate template that runs as part of the deployment

It should probably skip this check for secure params like it does in other parts.

I can raise a separete bug for this if you think its necessary. Thanks for all your work with this :)

@bmoore-msft
Copy link
Contributor

@stephenpope - can you go ahead and open a new bug for your new case?

bmoore-msft pushed a commit that referenced this issue Dec 3, 2021
* Test-AzTemplate:  Adding support for IsInnerTemplate.  Scaffolding for #492.

* Outputs-Must-Be-Present-In-Template-Parameters:  Adding [switch]$IsInnerTemplate and refactoring conditions under which the test are skipped.

* Resolve-JSONContent:  Allowing a property index (helps #495)

* Expand-AzTemplate:  Adding InnerTemplates to each file in FolderFiles (helps fix #495)

* Test-AzTemplate:  Expanding InnerTemplates correctly for each file in a folder (fixes #495)

* Adding test case to validate correct expansion of InnerTemplates/TemplateText (validating #495)

* Expand-AzTemplate: Slightly Updating Inline Documentation.

* Simplifying Unit Tests

* Resolve-JSONContent:  Allowing a match segment to have both a property and an index

* Test/Expand-AzTemplate:  Adding InnerTemplatesText, using it to pass inner templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants