1

I'm having the following syntax error in my yaml "can not read a block mapping entry; a multiline key may not be an implicit key"

not sure i'm why my array values are causing issues.

service: my-app

package:
  individually: true

provider:
  name: aws
  runtime: python3.8
  region: us-east-1
  stage: dev

functions:
  app:
    package:
      include:
        - "main.py"
      exclude:
        - "requirements.txt"
        - "package.json"
        - "package-lock.json"
        - ".serverless/**"
        - ".virtualenv/**"
        - "node_modules/**"
    handler: main.handler
    environment:
      STAGE: ${self:provider.stage}
    layers:
      - { Ref: PythonRequirementsLambdaLayer }
    events:
      - http:
          method: any
          path: /{proxy+}

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: true
    layer:
      name: app-layer
      description: app-layer
      compatibleRuntimes:
        - python3.8
vee
  • 680
  • 1
  • 10
  • 27
  • 1
    After running it through yaml parser, it complained about illegal utf characters, for example on line 11. Maybe this is releated? – majkrzak Jun 18 '21 at 17:33
  • deleted the utf white spaces in my edit – vee Jun 18 '21 at 17:35
  • 1
    The YAML you posted is syntactically valid. The error you posted tells us that a syntactic error is encountered when parsing a YAML file. Make sure that the code you posted is actually the code in which the error occurs. If unsure, describe in more detail what you are doing and how you are assuming that this YAML file causes the error. Post any additional information about the error (e.g. line number if available). – flyx Jun 18 '21 at 23:11

1 Answers1

1

If you are having trouble with YAML you can use this to help you format it for free: https://jsonformatter.org/yaml-formatter

According to the formatter, it looks like the formatting could look a little cleaner here:

environment:
  STAGE: ${self:provider.stage}
layers:
  - { Ref: PythonRequirementsLambdaLayer }
events:
  - http:
      method: any
      path: /{proxy+}

Please change the formatting to look like this:

environment:
  STAGE: '${self:provider.stage}'
layers:
  - Ref: PythonRequirementsLambdaLayer
events:
  - http:
      method: any
      path: '/{proxy+}'

Try using this format and see if it has any effect.

Technoob1984
  • 172
  • 9
  • 2
    This answer is not helpful. It doesn't describe what's wrong, or how the changed code will fix it. Actually, the fact that the original YAML got accepted by the formatter shows that it is already syntactically valid. The various edits the formatter makes do not change the semantics of the YAML at all (unsurprising, since it is a formatter). – flyx Jun 18 '21 at 23:06
  • @flyx, I changed around some wording. Please let me know what you think. Thanks – Technoob1984 Jun 19 '21 at 02:15
  • There are two scenarios where using a formatter would fix the issue: 1) the used YAML implementation is wrong – because it rejects the original form of valid YAML but accepts the modified form, even though they are semantically equivalent. 2) The formatter is wrong – because it changes the semantics of the YAML, which a formatter ought not do. In this example, we can see that 2) is not applicable because the modified YAML is, indeed, semantically equivalent to the original. 1) is possible but rather unlikely and if you suggest it, you should have some evidence or rather post it as comment. – flyx Jun 20 '21 at 10:43
  • 1
    How funny would it be if the person that asked the question tried out what I said and it worked? It might not work in this case, but anyone who might need a good formatter, that one is a pretty good free one. If this isn't the answer, hopefully someone like @flyx can give a more helpful answer. – Technoob1984 Jun 20 '21 at 23:42
  • @flyx, My post was marked as the right answer, and sometimes I can be petty. I am sure you know a lot, but I was right this time.... – Technoob1984 May 19 '22 at 12:51