Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define or recommend YAML schema supported #3962

Closed
Tracked by #3963
mx-psi opened this issue Mar 25, 2024 · 2 comments · Fixed by #3973
Closed
Tracked by #3963

Define or recommend YAML schema supported #3962

mx-psi opened this issue Mar 25, 2024 · 2 comments · Fixed by #3973
Labels
area:configuration Related to configuring the SDK triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted

Comments

@mx-psi
Copy link
Member

mx-psi commented Mar 25, 2024

Current spec wording says that:

YAML configuration files SHOULD follow YAML spec revision >= 1.2.

This leaves some ambiguity as YAML supports several 'schemas' (ways of interpreting the values that are not explicitly marked with a type tag). The YAML spec recommends the Core schema (although, IIUC, this recommendation is not normative).

To give a concrete example, in Go, the main YAML parsing libraries (1, 2), both support the YAML 1.1 0 leading octal syntax notation, where 0123 is equivalent to 0o123 or 83, while the YAML 1.2 core schema does not. If this is not the case in other languages, differences when interpreting integer literals could lead to hard-to-debug and unintuitive results.

The SDK configuration spec should recommend what YAML schema to use, and if possible explicitly define the recommended behavior with 0 leading integer literals.

@jack-berg jack-berg transferred this issue from open-telemetry/opentelemetry-configuration Mar 25, 2024
@jack-berg jack-berg added the area:configuration Related to configuring the SDK label Mar 25, 2024
@trask trask added the triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted label Mar 26, 2024
@trask
Copy link
Member

trask commented Mar 26, 2024

cc @open-telemetry/configuration-maintainers

@mx-psi
Copy link
Member Author

mx-psi commented Apr 2, 2024

#3973 proposes to follow the core schema

jack-berg added a commit that referenced this issue May 7, 2024
…ollow (#3973)

Fixes #3962

## Changes

Specifies the YAML schema to follow. A schema is a set of YAML tags
(i.e. types) and a way to assign types.

YAML 1.2 recommends the 'Core schema': the types are those of JSON.
Scalars are resolved as one would expect, see
[here](https://yaml.org/spec/1.2.2/#103-core-schema) for the details.

One important difference with the way that YAML 1.1 used to work is that
integer scalars starting with a `0` are interpreted as being written in
decimal notation; e.g. `0123` parses to the integer 123 instead of the
integer 83 (you can still use octal notation in YAML 1.2 by using
`0o123`). Some YAML parsers deviate from the core schema in how this
works, for example, both of the more commonly used YAML parsing
libraries in Golang parse `0123` as 83
([go-yaml/yaml](https://github.com/go-yaml/yaml?tab=readme-ov-file#compatibility)
and
[goccy/go-yaml](https://github.com/goccy/go-yaml/blob/4653a1bb5c0047bb37280ac341e2f091cb44352f/ast/ast.go#L326)).
**This may make it a bit difficult to strictly follow this requirement
in some languages**.

For non-trivial changes, follow the [change proposal
process](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CONTRIBUTING.md#proposing-a-change).

* [x] Related issues #3962, part of #3963

---------

Co-authored-by: Robert Pająk <[email protected]>
Co-authored-by: jack-berg <[email protected]>
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this issue Oct 31, 2024
…ollow (open-telemetry#3973)

Fixes open-telemetry#3962

## Changes

Specifies the YAML schema to follow. A schema is a set of YAML tags
(i.e. types) and a way to assign types.

YAML 1.2 recommends the 'Core schema': the types are those of JSON.
Scalars are resolved as one would expect, see
[here](https://yaml.org/spec/1.2.2/#103-core-schema) for the details.

One important difference with the way that YAML 1.1 used to work is that
integer scalars starting with a `0` are interpreted as being written in
decimal notation; e.g. `0123` parses to the integer 123 instead of the
integer 83 (you can still use octal notation in YAML 1.2 by using
`0o123`). Some YAML parsers deviate from the core schema in how this
works, for example, both of the more commonly used YAML parsing
libraries in Golang parse `0123` as 83
([go-yaml/yaml](https://github.com/go-yaml/yaml?tab=readme-ov-file#compatibility)
and
[goccy/go-yaml](https://github.com/goccy/go-yaml/blob/4653a1bb5c0047bb37280ac341e2f091cb44352f/ast/ast.go#L326)).
**This may make it a bit difficult to strictly follow this requirement
in some languages**.

For non-trivial changes, follow the [change proposal
process](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CONTRIBUTING.md#proposing-a-change).

* [x] Related issues open-telemetry#3962, part of open-telemetry#3963

---------

Co-authored-by: Robert Pająk <[email protected]>
Co-authored-by: jack-berg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:configuration Related to configuring the SDK triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted
Projects
None yet
4 participants