58

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

ADDATTEMPTING: 'Tentative d ajout '
ATTEMPTINGTOGIVE: 'Tenter de donner '
ATTEMPTINGTOSET1: 'Tentative de définition '
ATTEMPTINGTOSET2: ' avec '
ALREADYEXISTS: 'Erreur. Package existe déjà’
CANCEL1: 'Annulation...'
(...)

Error

ERROR:

while parsing a block mapping
  in "<unicode string>", line 1, column 1:
    ADDATTEMPTING: 'Tentative d ajout '
    ^
expected <block end>, but found '<scalar>'
  in "<unicode string>", line 6, column 11:
    CANCEL1: 'Annulation...'
              ^
0

6 Answers 6

51

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.

2
  • 22
    I had this same error, but for me it was an indentation issue(!)
    – ben3000
    Jan 15, 2016 at 9:01
  • 1
    I was facing the same error while starting storm nimbus daemon. Solved the error with replacing " --> ' in storm.yaml file. Thanks. Apr 10, 2018 at 3:07
48

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
22

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.

14

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.

8

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

2

I got same issue and found that there is space in next line which combine with content of yml. For solution i just remove that space. Thanks

Not the answer you're looking for? Browse other questions tagged or ask your own question.