Skip to content

[58_maintenance] fix: UnionFields::from_iter should validate input - #11763

Merged
alamb merged 1 commit into
apache:58_maintenancefrom
Jefffrey:backport_11533_58
Oct 21, 2026
Merged

alamb merged 1 commit into
apache:58_maintenancefrom
Jefffrey:backport_11533_58

Conversation

@Jefffrey

Copy link
Copy Markdown
Contributor

# Which issue does this PR close?

<!--
It is not necessary to raise an issue, but it is encouraged if it is a
non-trivial
enhancement/bug.

If this PR relates to an existing issue, but does not fully resolve it,
please change
the wording below from "Closes #NNN" to "Relates to #NNN" or "Part of
#NNN" to avoid
false closing an issue.
-->

- None

# Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the
issue then this section is not needed. Explaining clearly why changes
are proposed
helps reviewers understand your changes and offer better suggestions for
fixes.

Please try to explain the problem you are trying to solve in terms of
the user-visible
behavior, rather than the implementation.
-->

Make it impossible to create an invalid `UnionFields` via safe APIs.
This makes it easier for downstream uses of `UnionFields` (in other
parts of the codebase), since they can rely on the data being valid,
instead of needing to check each time.

# What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is
sometimes worth providing a summary of the individual changes in this
PR.
-->

Make sure `UnionFields::from_iter` validates its input before
construction a `UnionFields`, similar to `UnionFields::try_new`

# Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they
covered by existing tests, if so identify these tests)?

If this PR claims a performance improvement, please include evidence
such as
benchmark results.

DO NOT simply paste a list of commands ran to verify the code; this is
what our
CI is for and it pollutes the PR. ONLY explain if testing was included
with this
PR, or why it wasn't.
-->

Added new unit test.

# Are there any significant user-facing changes?

<!--
Significant user-facing changes include:
- Breaking public API change
- Significant change to existing functionality (e.g. function returns
something different)

These need to be explicitly called out to ensure we have proper
documentation if
required and to ensure we follow proper semantic versioning.

DO NOT restate the changes of this PR; if a bug was fixed and already
explained
above, we don't need this to be restated as a user-facing change.
-->

`UnionFields::from_iter` can now panic on invalid input data. This can
be reachable via a `collect()` into a `UnionFields` for example.
@Jefffrey Jefffrey added the bug Squash those bugs label Oct 21, 2026
@Jefffrey Jefffrey changed the title fix: UnionFields::from_iter should validate input (#11533) [58_maintenance] fix: UnionFields::from_iter should validate input Oct 21, 2026
@Jefffrey
Jefffrey marked this pull request as ready for review October 21, 2026 12:09
@alamb

alamb commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Merging as MSRV failure is unrelated. I will fix in this PR

@alamb
alamb merged commit 63a929e into apache:58_maintenance Oct 21, 2026
26 of 29 checks passed
@Jefffrey
Jefffrey deleted the backport_11533_58 branch October 21, 2026 23:44
Jefffrey added a commit that referenced this pull request Oct 22, 2026
…stall-action & pinning ubuntu (#11778)

# Which issue does this PR close?

- N/A, CI fix for `58_maintenance`. Same change as #11777 on
`57_maintenance`.

# Rationale for this change

The `Verify MSRV` job fails on every PR against `58_maintenance` (for
example #11767 and #11763) for reasons unrelated to those PRs:

```
error: cannot install package `cargo-msrv 0.19.5`, it requires rustc 1.94.1 or newer, while the currently active rustc version is 1.91.1
`cargo-msrv 0.19.3` supports rustc 1.91.1
```

`cargo-msrv` 0.19.4 and 0.19.5 were released today (2026-10-21) and
require rustc 1.94.1, but `58_maintenance` pins the toolchain to 1.91 in
`rust-toolchain.toml`. `cargo install cargo-msrv --locked` does not help
because `--locked` only pins the dependency graph, not the `cargo-msrv`
version itself.

# What changes are included in this PR?

Install `cargo-msrv` using `taiki-e/install-action` (which downloads a
prebuilt binary and does not need to compile anything with the pinned
toolchain), the same way `main` does since #10589. The action is pinned
to the same commit as on `main`.

# Are these changes tested?

CI

# Are there any user-facing changes?

No, CI only.

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Jefffrey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants