Error parsing yaml file: mapping values are not allowed here

Google App-EngineYaml

Google App-Engine Problem Overview


I want to upload an app to Google App Engine:

I get this

Error parsing yaml file:
mapping values are not allowed here
  in "/home/antonio/Desktop/ATI/climate-change/app.yaml", line 2, column 8 

When running

./appcfg.py update /home/antonio/Desktop/ATI/climate-change

with this app.yaml file:

application:climate-change
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.app

line 2, column 8 corresponds to the version line. What is wrong here? Btw, I'm using Ubuntu 12.04 here.

Google App-Engine Solutions


Solution 1 - Google App-Engine

Change

application:climate-change

to

application: climate-change

The space after the colon is mandatory in yaml if you want a key-value pair. (See http://www.yaml.org/spec/1.2/spec.html#id2759963)

Solution 2 - Google App-Engine

Another cause is wrong indentation which means trying to create the wrong objects. I've just fixed one in a Kubernetes Ingress definition:

Wrong

- path: / 
    backend: 
      serviceName: <service_name> 
      servicePort: <port> 

Correct

- path: /
  backend:
    serviceName: <service_name>
    servicePort: <port>

Solution 3 - Google App-Engine

Or, if spacing is not the problem, it might want the parent directory name rather than the file name.

Not $ dev_appserver helloapp.py
But $ dev_appserver hello/

For example:

Johns-Mac:hello john$ dev_appserver.py helloworld.py
Traceback (most recent call last):
  File "/usr/local/bin/dev_appserver.py", line 82, in <module>
    _run_file(__file__, globals())
...
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 212, in _GenerateEventParameters
    raise yaml_errors.EventListenerYAMLError(e)
google.appengine.api.yaml_errors.EventListenerYAMLError: mapping values are not allowed here
  in "helloworld.py", line 3, column 39

Versus

Johns-Mac:hello john$ cd ..
Johns-Mac:fbm john$ dev_appserver.py hello/
INFO     2014-09-15 11:44:27,828 api_server.py:171] Starting API server at: http://localhost:61049
INFO     2014-09-15 11:44:27,831 dispatcher.py:183] Starting module "default" running at: http://localhost:8080

Solution 4 - Google App-Engine

Incorrect:

people:
  empId: 123
  empName: John
    empDept: IT

Correct:

people:
  emp:
    id: 123
    name: John
    dept: IT

Solution 5 - Google App-Engine

Maybe this will help someone else, but I've seen this error when the RHS of the mapping contains a colon without enclosing quotes, such as:

someKey: another key: Change to make today: work out more

should be

someKey: another key: "Change to make today: work out more"

Solution 6 - Google App-Engine

I've seen this error in a similar situation to mentioned in Joe's answer:

description: Too high 5xx responses rate: {{ .Value }} > 0.05

We have a colon in description value. So, the problem is in missing quotes around description value. It can be resolved by adding quotes:

description: 'Too high 5xx responses rate: {{ .Value }} > 0.05'

Solution 7 - Google App-Engine

There are couple of issues in the yaml file as mentioned by most, with yaml files normally it gets messy to identify the issue,

fortunately it can be identified easily with tools like yaml lint and you may not require help from the community.

Install it

npm install -g yaml-lint

Here is how you can validate

E:\githubRepos\prometheus-sql-exporter-usage>yamllint docker-compose.yaml
√ YAML Lint successful.

Solution 8 - Google App-Engine

My issue was a missing set of quotes;

Foo: bar 'baz'

should be

Foo: "bar 'baz'"

Solution 9 - Google App-Engine

In our case, we had weird dash () instead of normal one (-) due to copy and paste.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionandandandandView Question on Stackoverflow
Solution 1 - Google App-EngineDave W. SmithView Answer on Stackoverflow
Solution 2 - Google App-EnginelcfdView Answer on Stackoverflow
Solution 3 - Google App-EngineJohn MeeView Answer on Stackoverflow
Solution 4 - Google App-EngineSajeevView Answer on Stackoverflow
Solution 5 - Google App-EngineJoeView Answer on Stackoverflow
Solution 6 - Google App-EngineEvgeny VeretennikovView Answer on Stackoverflow
Solution 7 - Google App-EnginecraftsmannadeemView Answer on Stackoverflow
Solution 8 - Google App-EngineGraham P HeathView Answer on Stackoverflow
Solution 9 - Google App-EnginemetasyncView Answer on Stackoverflow