Skip to content

[configoptional] Make Unmarshal into None[T] match unmarshal into (*T)(nil) #13168

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

Merged

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Jun 6, 2025

Description

Makes it so that unmarshaling into a None[T] is equivalent to unmarshaling into a (*T)(nil).
The goal is to be able to do #13109 without introducing any changes to the behavior.

Needs #13161.

Testing

Add a unit test to compare the behavior of unmarshaling into (*T)(nil) with that of unmarshaling into None[T]

Documentation

Amend docstrings

@github-actions github-actions bot requested a review from evan-bradley June 6, 2025 10:00
@mx-psi mx-psi force-pushed the mx-psi/configoptional-to-none-unmarshal branch from 5cd0415 to 53bdd95 Compare June 6, 2025 10:05
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.27%. Comparing base (1881912) to head (b5e73af).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13168   +/-   ##
=======================================
  Coverage   91.27%   91.27%           
=======================================
  Files         510      510           
  Lines       28753    28758    +5     
=======================================
+ Hits        26245    26250    +5     
  Misses       1993     1993           
  Partials      515      515           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mx-psi mx-psi force-pushed the mx-psi/configoptional-to-none-unmarshal branch from 53bdd95 to e493250 Compare June 6, 2025 11:22
github-merge-queue bot pushed a commit that referenced this pull request Jun 9, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Amends `ToStringMap` so that it returns `map[string]any(nil)` if the map
used to create this `Conf` was nil. Currently it returns an empty map.

I consider this a bug since, while not explicitly undocumented, I would
expect the following two properties to be true, and they were not before
this change:
1. For any map `m` without `expandedValue`s,
`NewFromStringMap(m).ToStringMap() == m`
2. For any map `m` without `expandedValue`s and any `path` referencing
an existing key in `m` with a `map[string]any` value,
`NewFromStringMap(m).Sub(path) == m[path[0]][path[1]][...][path[N]]`

<!-- Issue number if applicable -->
#### Link to tracking issue

I need this to be able to distinguish between 

```
foo:
   bar:
```

and

```
foo:
  bar: {}
```

which currently have different behaviors when mapping to pointers.

The goal is to be able to do #13168
@mx-psi mx-psi force-pushed the mx-psi/configoptional-to-none-unmarshal branch from e493250 to 9da4ec3 Compare June 9, 2025 11:41
@mx-psi mx-psi marked this pull request as ready for review June 9, 2025 11:45
@mx-psi mx-psi requested a review from a team as a code owner June 9, 2025 11:45
@mx-psi
Copy link
Member Author

mx-psi commented Jun 9, 2025

I will add a changelog if this does not get merged before today's release

@mx-psi mx-psi added this pull request to the merge queue Jun 10, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 10, 2025
@mx-psi mx-psi enabled auto-merge June 10, 2025 13:44
@mx-psi mx-psi added this pull request to the merge queue Jun 10, 2025
Merged via the queue into open-telemetry:main with commit 1245105 Jun 10, 2025
64 of 73 checks passed
@mx-psi mx-psi deleted the mx-psi/configoptional-to-none-unmarshal branch June 10, 2025 14:15
github-merge-queue bot pushed a commit that referenced this pull request Jun 12, 2025
)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Use flavor instead of `hasValue` and `notNone`

<!-- Issue number if applicable -->
#### Link to tracking issue

Updates #13181 using
#13168 (comment)
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.

4 participants