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

Handle normalization of dyn.KindTime into an any type #1836

Merged
merged 2 commits into from
Oct 17, 2024
Merged

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Oct 17, 2024

Changes

The issue reported in #1828 illustrates how using a YAML timestamp-like value (a date in this case) causes an issue during conversion to and from the typed configuration tree.

We use the AsAny() function on the dyn.Value when normalizing for the any type. We only use the any type for variable values, because they can assume every type. The AsAny() function returns a time.Time for the time value during conversion to the typed configuration tree. Upon conversion from the typed configuration tree back into the dynamic configuration tree, we cannot distinguish a time.Time struct from any other struct.

To address this, we use the underlying string value of the time value when we normalize for the any type.

Fixes #1828.

Tests

Existing unit tests pass

The issue reported in #1828 illustrates how using a YAML timestamp-like value
(a date in this case) causes an issue during conversion to and from the typed
configuration tree.

We use the `AsAny()` function on the `dyn.Value` when normalizing for the any
type. We only use the any type for variable values, because they can assume
every type. The `AsAny()` function returns a `time.Time` for the time value
during conversion **to** the typed configuration tree. Upon conversion **from**
the typed configuration tree back into the dynamic configuration tree, we
cannot distinguish a `time.Time` struct from any other struct.

To address this, we use the underlying string value of the time value when we
normalize for the any type.

Fixes #1828.
@pietern pietern added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit e4d039a Oct 17, 2024
10 checks passed
@pietern pietern deleted the issue-1828 branch October 17, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting an error as unhandled type: time
2 participants