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

Bug for nested instance referencing adjacent nested instance #692

Closed
3 tasks done
michaeltlombardi opened this issue Mar 13, 2025 · 1 comment · Fixed by #695
Closed
3 tasks done

Bug for nested instance referencing adjacent nested instance #692

michaeltlombardi opened this issue Mar 13, 2025 · 1 comment · Fixed by #695
Assignees
Labels
Issue-Bug Something isn't working Need-Review

Comments

@michaeltlombardi
Copy link
Collaborator

michaeltlombardi commented Mar 13, 2025

Prerequisites

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

Summary

Updating the documentation for nested instances, my prior examples no longer work.

Steps to reproduce

Consider this set of minimal repro documents:

  1. Working references/dependencies, top-level resources.

    repro.working.dsc.yaml document
    # repro.working.dsc.yaml
    $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
    resources:
    - name: Deeply nested OSInfo
      type: Microsoft/OSInfo
      properties: {}
    # The deeply nested echo references and depends on the adjacent
    # deeply nested OSInfo.
    - name: Deeply nested echo
      type: Microsoft.DSC.Debug/Echo
      properties:
        output:  >-
          [reference(
            resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')
          )]
      dependsOn:
        - "[resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')]"
    dsc config get --file ./repro.working.dsc.yaml
    Resultmetadata: Microsoft.DSC: version: 3.0.0 operation: get executionType: actual startDatetime: 2025-03-13T16:26:48.071242900-05:00 endDatetime: 2025-03-13T16:26:48.950015-05:00 duration: PT0.8787721S securityContext: restricted results: - metadata: Microsoft.DSC: duration: PT0.055847S name: Deeply nested OSInfo type: Microsoft/OSInfo result: actualState: $id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json family: Windows version: 10.0.26100 edition: Windows 11 Enterprise bitness: '64' architecture: x86_64 - metadata: Microsoft.DSC: duration: PT0.0861504S name: Deeply nested echo type: Microsoft.DSC.Debug/Echo result: actualState: output: $id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json family: Windows version: 10.0.26100 edition: Windows 11 Enterprise bitness: '64' architecture: x86_64 messages: [] hadErrors: false
  2. Failing reference, nested in a group.

    repro.failing.dsc.yaml document
    $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
    resources:
    - name: Nested Group
      type: Microsoft.DSC/Group
      properties:
        $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
        resources:
        - name: Deeply nested OSInfo
          type: Microsoft/OSInfo
          properties: {}
        # The deeply nested echo references and depends on the adjacent
        # deeply nested OSInfo.
        - name: Deeply nested echo
          type: Microsoft.DSC.Debug/Echo
          properties:
            output:  >-
              [reference(
                resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')
              )]
          dependsOn:
            - "[resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')]"
    dsc config get --file .\repro.failing.dsc.yaml
    Result
    2025-03-13T21:31:48.344691Z ERROR Parser: Invalid resourceId or resource has not executed yet: Microsoft/OSInfo:Deeply nested OSInfo

Expected behavior

The expressions in the nested instance are deferred from the top level and processed in the Group resource instance.

Actual behavior

It looks like DSC tries to resolve the references/resources before handing off to the group:

2025-03-13T21:36:01.947305Z DEBUG dsc::subcommand: 311: No parameters specified
2025-03-13T21:36:01.948364Z  INFO dsc_lib::configure: 582: No parameters defined in configuration and no parameters input
2025-03-13T21:36:01.949028Z DEBUG dsc_lib::configure: 650: No variables defined in configuration
2025-03-13T21:36:01.949591Z DEBUG dsc_lib::configure::depends_on: 27: Getting resource invocation order
2025-03-13T21:36:01.950488Z DEBUG dsc_lib::configure::depends_on: 90: Resource invocation order: [Resource { resource_type: "Microsoft.DSC/Group", name: "Nested Group", depends_on: None, properties: Some({"$schema": String("https://aka.ms/dsc/schemas/v3/bundled/config/document.json"), "resources": Array [Object {"name": String("Deeply nested OSInfo"), "type": String("Microsoft/OSInfo"), "properties": Object {}}, Object {"name": String("Deeply nested echo"), "type": String("Microsoft.DSC.Debug/Echo"), "properties": Object {"output": String("[reference(\n  resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')\n)]")}, "dependsOn": Array [String("[resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')]")]}]}), metadata: None }]
2025-03-13T21:36:01.952158Z DEBUG dsc_lib::configure: 729: Invoke property expressions
2025-03-13T21:36:01.953485Z DEBUG dsc_lib::parser: 48: Parsing statement: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
2025-03-13T21:36:01.954699Z DEBUG dsc_lib::parser: 72: Parsing string literal: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
2025-03-13T21:36:01.955950Z DEBUG dsc_lib::configure: 729: Invoke property expressions
2025-03-13T21:36:01.956901Z DEBUG dsc_lib::parser: 48: Parsing statement: Deeply nested OSInfo
2025-03-13T21:36:01.958075Z DEBUG dsc_lib::parser: 72: Parsing string literal: Deeply nested OSInfo
2025-03-13T21:36:01.958952Z DEBUG dsc_lib::parser: 48: Parsing statement: Microsoft/OSInfo
2025-03-13T21:36:01.959564Z DEBUG dsc_lib::parser: 72: Parsing string literal: Microsoft/OSInfo
2025-03-13T21:36:01.960188Z DEBUG dsc_lib::configure: 729: Invoke property expressions
2025-03-13T21:36:01.960728Z DEBUG dsc_lib::configure: 729: Invoke property expressions
2025-03-13T21:36:01.961261Z DEBUG dsc_lib::parser: 48: Parsing statement: Deeply nested echo
2025-03-13T21:36:01.961772Z DEBUG dsc_lib::parser: 72: Parsing string literal: Deeply nested echo
2025-03-13T21:36:01.962270Z DEBUG dsc_lib::parser: 48: Parsing statement: Microsoft.DSC.Debug/Echo
2025-03-13T21:36:01.962775Z DEBUG dsc_lib::parser: 72: Parsing string literal: Microsoft.DSC.Debug/Echo
2025-03-13T21:36:01.963264Z DEBUG dsc_lib::configure: 729: Invoke property expressions
2025-03-13T21:36:01.963786Z DEBUG dsc_lib::parser: 48: Parsing statement: [reference(
  resourceId('Microsoft/OSInfo', 'Deeply nested OSInfo')
)]
2025-03-13T21:36:01.964348Z DEBUG dsc_lib::parser: 84: Parsing expression
2025-03-13T21:36:01.964978Z DEBUG dsc_lib::parser::expressions: 43: Parsing function '{Node function (0, 1) - (2, 1)}'    
2025-03-13T21:36:01.965516Z DEBUG dsc_lib::parser::expressions: 43: Parsing function '{Node function (1, 2) - (1, 56)}'   
2025-03-13T21:36:01.966093Z DEBUG dsc_lib::parser::functions: 57: Function name: 'resourceId'
2025-03-13T21:36:01.966630Z DEBUG dsc_lib::parser::functions: 57: Function name: 'reference'
2025-03-13T21:36:01.967136Z DEBUG dsc_lib::parser::functions: 75: Argument is an expression
2025-03-13T21:36:01.967631Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("Microsoft/OSInfo")'       
2025-03-13T21:36:01.968438Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("Deeply nested OSInfo")'   
2025-03-13T21:36:01.969379Z DEBUG dsc_lib::functions::reference: 28: reference function
2025-03-13T21:36:01.971009Z ERROR dsc::subcommand: 68: Parser: Invalid resourceId or resource has not executed yet: Microsoft/OSInfo:Deeply nested OSInfo

Error details

2025-03-13T21:31:48.344691Z ERROR Parser: Invalid resourceId or resource has not executed yet: Microsoft/OSInfo:Deeply nested OSInfo

Environment data

N/A

Version

3.0.0

Visuals

No response

@michaeltlombardi michaeltlombardi added Issue-Bug Something isn't working Need-Review labels Mar 13, 2025
@SteveL-MSFT
Copy link
Member

Based on the traces, it appears the problem is that there is recursive expression invocation happening before the Group resource is even invoked. I think the problem right now is that the intent is to allow expressions in deeply nested objects, but the engine doesn't differentiate a Group type resource from an arbitrary property object. I think the fix is for it to skip parsing expressions when the resource type is a Group.

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 Need-Review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants