Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "mapping values are not allowed in this context " error in yaml file?

I've browsed similar questions and believe i've applied all that i've been able to glean from answers.

I have a .yml file where as far as I can tell each element is formatted identically. And yet according to YamlLint.com

(<unknown>): mapping values are not allowed in this context at line 119 column 16

In this case, line 119 is the line containing the second instance the word "transitions" below. That I can tell each element is formatted identically. Am I missing something here?

  landingPage:     include: false     transitions:       -         condition:location         nextState:location    location:     include:false     transitions:       -         condition:excluded         nextState:excluded    excluded:     include:false     transitions:       -         condition:excluded         nextState: excluded       -         condition:age         nextState:age  
like image 963
Merrill Cook Avatar asked Jun 15 '19 16:06

Merrill Cook


People also ask

What is a mapping value in YAML?

Flow mappings in YAML represent the unordered collection of key value pairs. They are also called as mapping node. Note that keys should be maintained unique. If there is a duplication of keys in flow mapping structure, it will generate an error.

What is a YAML file?

YAML is a data serialization language that is often used for writing configuration files. Depending on whom you ask, YAML stands for yet another markup language or YAML ain't markup language (a recursive acronym), which emphasizes that YAML is for data, not documents.

What is YAML syntax?

YAML is a digestible data serialization language often used to create configuration files with any programming language. Designed for human interaction, YAML is a strict superset of JSON, another data serialization language. But because it's a strict superset, it can do everything that JSON can and more.


2 Answers

You cannot have a multiline plain scalar, such as your include:false transitions be the key to a mapping, that is why you get the mapping values not allowed in this context error.

Either you forgot that you have to have a space after the value indicator (:), and you meant to do:

        include: false         transitions: 

or you need to quote your multi-line scalar:

        'include:false         transitions': 

or you need to put that plain scalar on one line:

        include:false transitions: 

please note that some libraries do not allow value indicators in a plain scalar at all, even if they are not followed by space

like image 130
Anthon Avatar answered Sep 26 '22 14:09

Anthon


we need to use space before ":" Then it will excecute check the yaml script in below http://www.yamllint.com/

like image 31
NMNS chaitanya Avatar answered Sep 25 '22 14:09

NMNS chaitanya