Expected block end YAML error

后端 未结 6 834

When pasting this YAML file into an online yaml parser, I got an expected block end error:

ADDATTEMPTING: \'Tentative d ajout \'
ATTEMPTINGTOGIVE: \'Tenter de do         


        
相关标签:
6条回答
  • 2021-02-05 01:51

    With YAML, remember that it is all about the spaces used to define configuration through the hierarchical structures (indents). Many problems encountered whilst parsing YAML documents simply stems from extra spaces (or not enough spaces) before a key value somewhere in the given YAML file.

    0 讨论(0)
  • 2021-02-05 01:53

    The line starting ALREADYEXISTS uses as the closing quote, it should be using '. The open quote on the next line (where the error is reported) is seen as the closing quote, and this mix up is causing the error.

    0 讨论(0)
  • 2021-02-05 02:00

    I would like to make this answer for meaningful, so the same kind of erroneous user can enjoy without feel any hassle.

    Actually, i was getting the same error but for the different reason, in my case I didn't used any kind of quoted, still getting the same error like expected <block end>, but found BlockMappingStart.

    I have solved it by fixing, the Alignment issue inside the same .yml file.

    If we don't manage the proper 'tab-space(Keyboard key)' for maintaining successor or ancestor then we have to phase such kind of things.

    Now i am doing well.

    0 讨论(0)
  • 2021-02-05 02:02

    This error also occurs if you use four-space instead of two-space indentation.

    e.g., the following would throw the error:

    fields:
        - metadata: {}
            name: colName
            nullable: true
    

    whereas changing indentation to two-spaces would fix it:

    fields:
      - metadata: {}
        name: colName
        nullable: true
    
    0 讨论(0)
  • 2021-02-05 02:09

    In my case, the error occured when I tried to pass a variable which was looking like a bytes-object (b"xxxx") but was actually a string.

    You can convert the string to a real bytes object like this:

    foo.strip('b"').replace("\\n", "\n").encode()
    
    0 讨论(0)
  • 2021-02-05 02:10

    YAML follows indentation structure very strictly. Even one space/tab can cause above issue. In my case it was just once space at the start.

    So make sure no extra spaces/tabs are introduced while updating YAML file

    0 讨论(0)
提交回复
热议问题