You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
panic: yaml: line 12: did not find expected key
goroutine 1 [running]:
main.main()
main.go:67 +0x70
Process finished with the exit code 2
It says there is an error on line number 12 ... which does not make sense given the input YAML.
package main
import (
"gopkg.in/yaml.v3"
)
varinputstring=`# Copyright 2024 Google LLC# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at# http:#www.apache.org/licenses/LICENSE-2.0# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.APIProxy: .revision: 1 .name: swagger-petstore-openapi-3-0 DisplayName: Swagger Petstore - OpenAPI 3.0 Description: |- This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at [http://swagger.io](http://swagger.io). In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3. Some useful links: - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore) - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)Policies: # Copyright 2024 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http:#www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #- SpikeArrest: .continueOnError: false .enabled: true .name: Spike-Arrest-1 DisplayName: Spike Arrest Properties: {} Identifier: .ref: client.ip Rate: 100pm - OASValidation: .continueOnError: false .enabled: true .name: OAS-Validate DisplayName: OAS-Validate Source: request OASResource: oas://spec.yaml`funcmain() {
yamlNode:= yaml.Node{}
iferr:=yaml.Unmarshal([]byte(input), &yamlNode); err!=nil {
panic(err)
}
}
Other tools I've tried (like yamllint.com) correctly identify the error as being on line 47
The text was updated successfully, but these errors were encountered:
I have this same problem, manifesting slightly differently... when using folding characters, the line numbers identified from the parser also don't correlate with the original file. For example:
28 description: |
29 Some field description
Accessing the yaml.Node.Line property while parsing the description returns 28.
This is a rather large problem for us, as I'm trying to write parsing logic that extracts segments from a YAML file for separate analysis and is capable of pointing back to their original location.
If this were to be fixed, I suspect we would need .RawLine and .RawColumn properties so as not to break any existing implementations, with analogous properties on the error.
Given the last release of this package was over two years ago, is it still actively maintained? What are the chances of being able to address this? Unfortunately other options for handling YAML in Go appear to be limited.
The program below outputs:
It says there is an error on line number 12 ... which does not make sense given the input YAML.
Other tools I've tried (like yamllint.com) correctly identify the error as being on line 47
The text was updated successfully, but these errors were encountered: