Skip to content

Conversation

gjcairo
Copy link
Contributor

@gjcairo gjcairo commented Jul 23, 2024

One of the assertions in the TextFormat fuzz-originated unit tests checked that we failed to decode a string built from a sequence of bytes. However, this sequence of bytes had invalid UTF8 characters. Foundation has improved in recent betas and now fails to build a String from this sequence (which it didn't before). This is causing the test to fail.

If the String couldn't have been constructed during fuzz testing, the test would have passed - see:

guard let str = String(data: Data(bytes), encoding: .utf8) else { return 0 }

We should tolerate the String not being constructed here without failing the test, as it's the correct (and current) behaviour. This means that after this PR, assertions will be skipped when a String cannot be constructed.
However, we shouldn't simply remove the failing assertion, because in the case Foundation introduces this bug again, we should make sure we're failing the TextFormat decoding.

@thomasvl
Copy link
Collaborator

Fyi - #1590 is the PR that removed the original test case. We'd pulled it in to be a unittest to help keep a better eye on the handling.

@thomasvl thomasvl merged commit bedea25 into apple:main Jul 23, 2024
10 checks passed
@gjcairo gjcairo deleted the fix-broken-test branch July 23, 2024 14:08
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.

2 participants