aman207
aman207

Reputation: 1150

Expected block end YAML error

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...'
              ^

Upvotes: 65

Views: 317143

Answers (7)

Chuck Smith
Chuck Smith

Reputation: 104

I got this error while working on a CloudFormation template in an effort to deploy a Lambda function to AWS:

expected <block end>, but found '<block mapping start>'
  in "<unicode string>", line 111, column 2:
     InitialLogPositions:
      ^

My spacing was off:

  KillSwitch:
    Type: String
    Default: "False"
    Description: "Use to control whether processing occurs"

 InitialLogPositions: 
    Type: String 

Once I added the extra space in front of InitialLogPositions everything worked. KillSwitch did correctly have 2 spaces in front of it, but not InitialLogPositions.

Upvotes: 0

ankit
ankit

Reputation: 2855

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

Upvotes: 3

Shashikant
Shashikant

Reputation: 91

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

Upvotes: 9

Michael M
Michael M

Reputation: 1379

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.

Upvotes: 15

Jared Wilber
Jared Wilber

Reputation: 6815

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

Upvotes: 50

Vishal Gajera
Vishal Gajera

Reputation: 4207

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.

Upvotes: 22

matt
matt

Reputation: 79813

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.

Upvotes: 55

Related Questions