Skip to content

Parser throws error on [ #1024

Description

Prerequisites

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

Summary

If the property value contains a [ the parser thinks its the beginning of a function.

Steps to reproduce

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Install Pester
  type: AnyPackageDsc/Package
  properties:
    Name: Pester
    Version: '[5.0,6.0)'
    Provider: AnyPackage.PSResourceGet\PSResourceGet
    Source: PSGallery
    Ensure: Present

Expected behavior

Parses string literal

Actual behavior

ERROR Parser: Unable to parse statement root: [5.0,6.0)

Error details

ERROR Parser: Unable to parse statement root: [5.0,6.0)

Environment data

7.6-preview4

Version

3.2-preview3

Visuals

No response

Activity

  1. SteveL-MSFT commented on Aug 4, 2025

    @SteveL-MSFT
    Member

    Per ARM rules, you need to "escape" the opening square bracket with a square bracket [[5.0.6.0] https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-expressions#escape-characters

    Maybe something we could do is check for this specific case and give a specific error message to escape it.

  2. ThomasNieto commented on Aug 4, 2025

    @ThomasNieto
    CollaboratorAuthor

    Steve Lee (@SteveL-MSFT) adding that extra [ didn't fix it.

     dsc config get -f C:\temp\module.dsc.config.yaml
    2025-08-04T18:58:33.316135Z ERROR Parser: Unable to parse statement root: [5.0,6.0)
    
    dsc config get -f C:\temp\module.dsc.config.yaml
    2025-08-04T18:59:06.891977Z ERROR Parser: Unable to parse statement root: [5.0,6.0]
    
  3. SteveL-MSFT commented on Aug 5, 2025

    @SteveL-MSFT
    Member
  4. SteveL-MSFT commented on Aug 5, 2025

    @SteveL-MSFT
    Member

    Thomas Nieto (@ThomasNieto) can you give me a repro using the Echo resource?

    Image
  5. ThomasNieto commented on Aug 5, 2025

    @ThomasNieto
    CollaboratorAuthor

    Steve Lee (@SteveL-MSFT) it works using Echo but not a PS Adapter resource.

  6. SteveL-MSFT commented on Aug 5, 2025

    @SteveL-MSFT
    Member

    @SteveL-MSFT it works using Echo but not a PS Adapter resource.

    Ok, in that case, I think the problem is that the string gets unescaped and passed to the adapter which then errors because the escape is missing. For now, you might be able to workaround it by double escaping: [[[5.0,6.0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions