Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2732

Inline YAML parsing fails sometimes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: 3.10.2
    • Fix Version/s: None
    • Component/s: Evaluation
    • Labels:
      None
    • Environment:
      macOS High Sierra (10.13.1)

      Description

      (attachment contains org-mode file for this bug report, for Nick )

      It seems the parsing of YAML strings fails or differs depending on how the YAML is specified. In particular, it seems that the "magic" parsing of YAML strings that start with "---\n" fails to parse in some cases.

      Version:

      cf-agent --version
      uname -a
      

      This works fine:

      bundle agent main
      {
       vars:
         "yaml" data => parseyaml("animals:
        - dog
        - cat
        - crow");
       reports:
         "animals = $(yaml[animals])";
      }
      
      R: animals = dog
      R: animals = cat
      R: animals = crow
      

      Embedding the newlines makes it fail:

      bundle agent main
      {
       vars:
         "yaml" data => parseyaml("animals:\n    - dog\n    - cat\n    - crow");
       reports:
         "animals = $(yaml[animals])";
      }
      
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
      R: animals = $(yaml[animals])
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression 'animals:\n    - dog\n    - cat\n    - crow'
      

      Inlined multi-line YAML works:

        bundle agent main
        {
         vars:
           "yaml" data => "---
      animals:
          - dog
          - cat
          - crow";
         reports:
           "animals = $(yaml[animals])";
        }
      
      R: animals = dog
      R: animals = cat
      R: animals = crow
      

      Inlined multi-line with embedded newlines again does not (BTW this is how it's shown in the documentation):

      bundle agent main
      {
       vars:
         "yaml" data => "---\nanimals:\n    - dog\n    - cat\n    - crow";
       reports:
         "animals = $(yaml[animals])";
      }
      
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
      R: animals = $(yaml[animals])
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
         error: Non-container from parsing YAML expression '---\nanimals:\n    - dog\n    - cat\n    - crow'
      

        Attachments

          Activity

            People

            • Assignee:
              a10003 Eystein Maloy Stenberg
              Reporter:
              zzamboni Diego Zamboni
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel