YAML Implicit keys need to be on a single line, Implicit map keys need to be followed by map values
Asked Answered
D

3

7
trigger:
- develop

pool:
  vmImage: windows-2019

- task: MSBuild@1
  inputs:
    solution: '**/*.sln'
- task: DownloadBuildArtifacts@1
  inputs:
    buildType: 'current'
    downloadType: 'single'
    itemPattern: '**/*.exe'
    downloadPath: '$(System.ArtifactsDirectory)'

I get an error with this YAML in both Azure DevOps and using the YAML extension for VS Code. I'm trying to build a Windows Service and then put the .exe file somewhere that I can download it.

Azure DevOps: azdo screenshot VSCode vscode screenshot

Error:

Implicit keys need to be on a single line, Implicit map keys need to be followed by map values

Daman answered 27/1, 2023 at 17:25 Comment(4)
Can you please paste the full yaml? From the screenshot it looks like something is wrong with line 10, but line 8 is lit red too.Replenish
Added image of full YAML. It's also in the question body.Daman
thanks, maybe you could also try to use a code block for your code snippet. meta.#251861Replenish
Just a note, this error is generic, and in my case it was because of tab/spaces mixes (so nothing to do with the key) hope it helps.Wellfavored
R
7

Although the error looks some what confusing, your are missing the keyword steps.


trigger:
- develop

pool: 
  vmImage: windows-2019

steps:
- task: MSBuild@1 
  inputs: 
    solution: '**/*.sln'
- task: DownloadBuildArtifacts@1 
  inputs: 
    buildType: 'current' 
    downloadType: 'single' 
    itemPattern: '**/*.exe' 
    downloadPath: '$(System.ArtifactsDirectory)' 

Replenish answered 27/1, 2023 at 22:20 Comment(0)
L
3

We've just run into the same error and it was being caused by invisible characters that appeared when we copied the code over from a Teams chat. We've removed these "spaces" and replaced them with regular spaces and it worked.

Lighten answered 5/5, 2023 at 17:18 Comment(0)
S
3

When I ran into this error, it was caused by the next line having an extra level of indentation.

Exact error text:

Nested mappings are not allowed in compact mappingsYAML
Implicit keys need to be on a single line

Incorrect

    MultiStockQtysResponse:
      type: array
      items:
        type: object
          required: [standardID, storeCode, qtyAvailable]

Correct

    MultiStockQtysResponse:
      type: array
      items:
        type: object
        required: [standardID, storeCode, qtyAvailable]

The error started on the line with type: object, but un-indenting required... fixed the error.

Schuck answered 22/1, 2024 at 18:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.