Open timothyanderson82 opened 2 years ago
i'm running into this issue now. Is there a fix for this? or any type of syntax to get around this?
Looks like I am getting the same issues with win_xml as well when I have an attribute of value in an xml document
The full traceback is:
You cannot call a method on a null-valued expression.
At line:188 char:13
+ $candidate = $xmlorig.CreateElement($xmlfragment.get_Docu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvokeMethodOnNull
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 188
fatal: [test.dev]: FAILED! => changed=false
msg: 'Unhandled exception while executing module: You cannot call a method on a null-valued expression.'
Looks like I am getting the same issues with win_xml as well when I have an attribute of value in an xml document
The full traceback is: You cannot call a method on a null-valued expression. At line:188 char:13 + $candidate = $xmlorig.CreateElement($xmlfragment.get_Docu ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvokeMethodOnNull ScriptStackTrace: at <ScriptBlock>, <No file>: line 188 fatal: [test.dev]: FAILED! => changed=false msg: 'Unhandled exception while executing module: You cannot call a method on a null-valued expression.'
I sadly don't think there's a fix for this. It works for everything else besides if you wanna build a site with the word value. Really Unfortunate.
I'm getting the same issue. Somebody please make a pull request where this line
https://github.com/ansible-collections/community.windows/blob/main/plugins/modules/win_iis_webapppool.ps1#L111
if ([bool]($attribute_value.PSobject.Properties -match "Value")) {
is replaced with
if ([bool]($attribute_value.PSobject.Properties.Name -eq "Value")) {
Root cause is that the string "Value"
is matched against collection of property objects of the $attribute_value
but from the context it can be deduced that "Value"
should only be matched against collection of names of those properties. Match should not be partial either, hence the -eq
operator.
SUMMARY
win_iis_webapppool module fails with the below error when the word "value" in the app pool name and you try and set attributes:
ISSUE TYPE
COMPONENT NAME
community.windows.win_iis_webapppool
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
I have tested this on Windows Server 2012 R2, Windows Server 2016 & Windows Server 2019
STEPS TO REPRODUCE
Blank IIS Target Web Server. Run the below playbook and note the failure above.
EXPECTED RESULTS
Create an app pool, set attributes provided in the attributes dict.
ACTUAL RESULTS
Creates the application pool and throws the below error when setting the attributes
POTENTIAL BUG
It looks like in this section of the powershell when the
Convert-ToPropertyValue
function is run for the current attribute value it is checking for a property named value and then setting the attribute_value to that property. but the match statement is finding the word value in the properties and incorrectly returning true.Statement calling the
Convert-ToPropertyValue
function for current attribute Value:Statement in
Convert-ToPropertyValue
checking for the Value property:Below script to reproduce this scenario:
Result: