Skip to content

Conversation

Clebam
Copy link
Contributor

@Clebam Clebam commented Feb 8, 2024

Summary

Linked to #264

Related Issues (if any)

#264

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified.

@Clebam Clebam requested a review from a team as a code owner February 8, 2024 14:32
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.98%. Comparing base (900a944) to head (3c1b39e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #292   +/-   ##
=======================================
  Coverage   91.98%   91.98%           
=======================================
  Files           6        6           
  Lines         711      711           
=======================================
  Hits          654      654           
  Misses         57       57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jordanbreen28 jordanbreen28 linked an issue Feb 8, 2024 that may be closed by this pull request
@Clebam
Copy link
Contributor Author

Clebam commented Feb 9, 2024

Hi @jordanbreen28 , for this one I 'm not sure what is going on.
I can see the specs are using dsc_xwebsite resources and not dsc_website (https://github.com/dsccommunity/WebAdministrationDsc) (though I don't think this is the main cause of the failure)

@jordanbreen28
Copy link
Contributor

jordanbreen28 commented Feb 9, 2024

hey @Clebam - yeah i don't think thats the issue as our nightly builds are passing. Something that has changed in this PR has caused it - Not to worry though! I'll be happy to collaborate, spin up an environment and take a look at this myself shortly. Appreciate all your work on these!

@jordanbreen28
Copy link
Contributor

@Clebam I've been looking into this some more, running tests and trying to get a working solution, but the more time I've spent on this I'm starting to think this maybe isn't the way to go 👎 I think a fix is more appropriate in the puppet-resource_api, and how it's compares the empty or nil enum values.

@Clebam
Copy link
Contributor Author

Clebam commented Feb 22, 2024

I gave a look at resource-api, it's a bit overwhelming at first glance. Not sure if I can spot something useful.

@jordanbreen28
Copy link
Contributor

@Clebam agreed, it is definitely a biggy.
No pressure. I can make note of this and bring it up with the team to get prioritised!

@Clebam
Copy link
Contributor Author

Clebam commented Feb 23, 2024

@jordanbreen28 However I'm curious to know what you saw that is going wrong with my fix. Maybe there is more I can do to it 🤔 (and I'm also interested if I can still try to use my quick fix in my env without breaking something. From my point of view, it did not have any wrong effects, but given you found issues, I'm a bit worried to merge it into my production environment 😓 )

@jordanbreen28
Copy link
Contributor

jordanbreen28 commented Feb 26, 2024

@Clebam actually disregard my previous message! This should work. I'm going to spend some more time in prying into the code to see if I can spot what is exactly happening here.

Could you rebase this off main? Some changes have went in, wondering if they effect the behaviour in anyway.

@Clebam Clebam force-pushed the fix_empty_string_nullification branch from 25efb36 to 96eb242 Compare February 28, 2024 13:06
@Clebam
Copy link
Contributor Author

Clebam commented Feb 29, 2024

@jordanbreen28, I rebased from main. If you have any logs from the puppet run that fails, I could give a look.

@jordanbreen28
Copy link
Contributor

jordanbreen28 commented Mar 4, 2024

@jordanbreen28, I rebased from main. If you have any logs from the puppet run that fails, I could give a look.

@Clebam apologies, I was off last week. I'll get to looking at this and providing some logs as soon as I can.
Whats interesting is I noticed this only fails on puppet 8 - with changes to strict variable settings from puppet 7 ~> 8, I can bet thats the issue.

@jordanbreen28
Copy link
Contributor

@Clebam so the issue here is that we are converting nil enums to empty strings even when that is not a valid enum value. So I would recommend not running this in any of your environments as this will cause unexpected behaviour! I'm sure there is a way we can convert only valid values..

Error: /Stage[main]/Main/Dsc_xwebsite[DefaultSite]: Could not evaluate: Provider returned data that does not match the Type Schema for `dsc_xwebsite[DefaultSite]`
 Value type mismatch:
    * dsc_bindinginfo: [{"bindinginformation"=>"*:80:", "certificatestorename"=>"", "certificatesubject"=>nil, "certificatethumbprint"=>"", "hostname"=>"", "ipaddress"=>"*", "port"=>80, "protocol"=>"http", "s
slflags"=>"0"}] (index 0 entry 'certificatestorename' expects an undef value or a match for Enum['My', 'WebHosting'], got '')

Debug: dsc_xwindowsfeature: Collecting data from the DSC Resource
Debug: dsc_xwindowsfeature: Canonicalized Resources: [{:dsc_displayname=>"ASP.NET 4.7", :dsc_ensure=>"Present", :dsc_includeallsubfeature=>false, :dsc_logpath=>nil, :dsc_name=>"Web-Asp-Net45", :name=>"AspNet4
5"}]
Debug: Current State: {:dsc_displayname=>"ASP.NET 4.7", :dsc_ensure=>"Present", :dsc_includeallsubfeature=>false, :dsc_logpath=>nil, :dsc_name=>"Web-Asp-Net45", :name=>"AspNet45"}
Debug: dsc_xwebsite: Collecting data from the DSC Resource
Error: /Stage[main]/Main/Dsc_xwebsite[NewWebsite]: Could not evaluate: Provider returned data that does not match the Type Schema for `dsc_xwebsite[NewWebsite]`
 Value type mismatch:
    * dsc_bindinginfo: [{"bindinginformation"=>"*:80:", "certificatestorename"=>"", "certificatesubject"=>nil, "certificatethumbprint"=>"", "hostname"=>"", "ipaddress"=>"*", "port"=>80, "protocol"=>"http", "s
slflags"=>"0"}] (index 0 entry 'certificatestorename' expects an undef value or a match for Enum['My', 'WebHosting'], got '')

The only way we can access the resource type properties is within the dsc_base_provider.rb, there is a similiar method implemented here which could be tweaked with some regex to fit the use case here.

@Clebam
Copy link
Contributor Author

Clebam commented Mar 4, 2024

I see. Not at work today but will give a shot tomorrow. At first glance the enum_values function I added might be useful here to know if '' (empty string) is among the valid values of the enum. Though I have to be careful to not override undefined values.

Enum['something', 'else', ''] myParam

myParam = '' ==> should be empty string
myParam (undefined) ==> should be nil

Will keep you updated tomorrow

@Clebam Clebam force-pushed the fix_empty_string_nullification branch from a51bd64 to 4945294 Compare March 5, 2024 14:47
@Clebam
Copy link
Contributor Author

Clebam commented Mar 5, 2024

@jordanbreen28 Seems to be working 😄
Please check if I did not alter the behavior you intended first. (I focused only on values that are supplied by in name_hash in order to avoid setting '' value instead of leaving the value unmanaged (for instance if for some reason it was set manually or another way)

@jordanbreen28
Copy link
Contributor

@Clebam amazing! Yes, like you said, let me spin up an environment and to just reassure this doesn't break the existing logic :) Looking good though!

@Clebam Clebam force-pushed the fix_empty_string_nullification branch 2 times, most recently from 3b410e6 to 3c1b39e Compare March 13, 2024 15:15
Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your work on this @Clebam

@jordanbreen28 jordanbreen28 merged commit 4001eb1 into puppetlabs:main Mar 13, 2024
@Clebam Clebam deleted the fix_empty_string_nullification branch March 13, 2024 17:24
david22swan added a commit that referenced this pull request Sep 25, 2024
Reinstating reverted change by Clebam with additional fix suggested by original author.

Original Fix: #292
Revert: #342
Reason for revert: #340
david22swan added a commit that referenced this pull request Sep 25, 2024
Reinstating reverted change by Clebam with additional fix suggested by original author.

Original PR: #292
Revert PR: #342
Reason for revert: #340
Original author: https://github.com/Clebam
garrettrowell pushed a commit to garrettrowell/ruby-pwsh that referenced this pull request Oct 17, 2024
Reinstating reverted change by Clebam with additional fix suggested by original author.

Original PR: puppetlabs#292
Revert PR: puppetlabs#342
Reason for revert: puppetlabs#340
Original author: https://github.com/Clebam
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.

ConvertTo-CanonicalResult incorreclty forces empty_string to null
3 participants