Skip to content

config export does not preserve incoming metadata #668

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

Closed
3 tasks done
JohnMcPMS opened this issue Mar 5, 2025 · 5 comments · Fixed by #679
Closed
3 tasks done

config export does not preserve incoming metadata #668

JohnMcPMS opened this issue Mar 5, 2025 · 5 comments · Fixed by #679
Assignees
Labels
Issue-Bug Something isn't working
Milestone

Comments

@JohnMcPMS
Copy link
Collaborator

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

When passing a configuration document to config export, the metadata in the original document is not in the output document.

Steps to reproduce

With this document:

# repro.yml
$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2023/08/config/document.json
metadata:
  winget:
    processor: dscv3
resources:
  - name: OS
    type: Microsoft/OSInfo
    properties:
      $id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json

The result of dsc config export repro.yml is:

$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2024/04/config/document.json
contentVersion: 1.0.0
resources:
- type: Microsoft/OSInfo
  name: Microsoft/OSInfo-0
  properties:
    $id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json
    family: Windows
    version: 10.0.23822
    edition: Windows 11 Enterprise
    bitness: '64'
    architecture: x86_64
metadata:
  Microsoft.DSC:
    version: 3.0.0
    operation: Export
    executionType: Actual
    startDatetime: 2025-03-05T09:10:15.418957600-08:00
    endDatetime: 2025-03-05T09:10:16.160492700-08:00
    duration: PT0.7415351S
    securityContext: Restricted

Expected behavior

Metadata properties *other* than `Microsoft.DSC` in the original document are in the resulting document.

Actual behavior

Only the `Microsoft.DSC` properties are in the output document.

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.23822
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

3.0.0-rc.1

Visuals

No response

@JohnMcPMS JohnMcPMS added Issue-Bug Something isn't working Need-Review labels Mar 5, 2025
@JohnMcPMS
Copy link
Collaborator Author

PS nuisance issue: requiring 1 property to be present, even for export resources, is annoying.

@SteveL-MSFT SteveL-MSFT added this to the 3.1-Approved milestone Mar 5, 2025
@SteveL-MSFT
Copy link
Member

PS nuisance issue: requiring 1 property to be present, even for export resources, is annoying.

properties is supposed to be optional. Can you provide a simple repro so I can see what error is returned?

@JohnMcPMS
Copy link
Collaborator Author

JohnMcPMS commented Mar 5, 2025

Works:

$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
  - name: OS
    type: Microsoft/OSInfo
    properties:
      $id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json

Both get 2025-03-05T20:04:06.676538Z ERROR Schema: null is not of type "object" when running dsc config export -f E:\Temp\os-export.yaml:

$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
  - name: OS
    type: Microsoft/OSInfo
    properties:
$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
  - name: OS
    type: Microsoft/OSInfo

@SteveL-MSFT
Copy link
Member

Workaround for now is to provide an empty object so it's not null:

$schema: https://github.com/raw/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
  - name: OS
    type: Microsoft/OSInfo
    properties: {}

However, I consider this a bug. Let me look into it to see if it's simple or complex to fix.

@SteveL-MSFT
Copy link
Member

@JohnMcPMS the properties problem is fixed via #675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants