Skip to content

Fix: Always export AdvancedSettings as array in SCSensitivityLabel #6375

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

Open
wants to merge 3 commits into
base: Dev
Choose a base branch
from

Conversation

Harikumar4
Copy link

@Harikumar4 Harikumar4 commented Jul 26, 2025

Pull Request (PR) description

This PR ensures that the AdvancedSettings property in the SCSensitivityLabel resource is always exported as an array block in the generated DSC configuration, even when there is only a single item. This improves consistency and prevents downstream issues when consuming the exported configuration.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
  • Resource parameter descriptions added/updated in the schema.mof. (Not applicable for this PR)
  • Resource documentation added/updated in README.md. (Not applicable for this PR)
  • Resource settings.json file contains all required permissions. (Not applicable for this PR)
  • Examples appropriately added/updated. (Not applicable for this PR)
  • Unit tests added/updated. (Not applicable for this PR)
  • New/changed code adheres to DSC Community Style Guidelines.

@Harikumar4
Copy link
Author

@Harikumar4 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@FabienTschanz
Copy link
Collaborator

FabienTschanz commented Jul 27, 2025

@Harikmar4 The CIM instance conversion you're trying to fix is based on the actual value of the property. To not meddle with the CIM conversion at the end, it's more appropriate to ensure that the property is an array. To fix this, update the following line:

# lines 361 to 363
if ($null -ne $label.Settings)
{
    # Add the [array] type indicator to the variable to enforce conversion to an array
    [array]$advancedSettingsValue = Convert-StringToAdvancedSettings -AdvancedSettings $label.Settings
}

This way, the export will look correctly:

SCSensitivityLabel "SCSensitivityLabel-defa4170-0d19-0005-0000-bc88714345d2"
{
    AdvancedSettings      = @(
         MSFT_SCLabelSetting{
             Key = "isparent"
             Value = "False"
        }
   );
...

This also reduces the PR size massively 😉

@Harikumar4
Copy link
Author

Thanks for the clarification.
I have updated the logic to

[array]$advancedSettingsValue = Convert-StringToAdvancedSettings -AdvancedSettings $label.Settings

This ensures that AdvancedSettings is always an array. Since $advancedSettingsValue is assigned directly in the export block ($result = @{} at line 642), a separate assignment like $Results.AdvancedSettings = $advancedSettingsValue isn’t necessary.
Let me know if you need any further changes.

@FabienTschanz
Copy link
Collaborator

LGTM, now we have to wait for approval and merge. Thank you for the fix 👍

@FabienTschanz
Copy link
Collaborator

@Harikumar4 Can you please update the issue link in the Pull Request description? The link is currently invalid. You can just type - Fixes #6321 without providing any link and GitHub will automatically determine the correct issue. This will allow us to automatically close the other issue once this Pull Request is merged. Thank you.

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

Successfully merging this pull request may close these issues.

[SCSensitivityLabel] AdvancedSettings seems to export a single item as a single item instead of an arrya
2 participants