Skip to content

tests(py): don't draw lone surrogates into a pyarrow string column - #103

Merged
adriangb merged 1 commit into
mainfrom
claude/fix-surrogate-flake
Aug 15, 2026
Merged

tests(py): don't draw lone surrogates into a pyarrow string column#103
adriangb merged 1 commit into
mainfrom
claude/fix-surrogate-flake

Conversation

@adriangb

Copy link
Copy Markdown
Owner

test_roundtrip_arbitrary_primitive_tables fails at random on main:

UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed
while generating 'table' from _mixed_tables()

st.text() draws from all of Unicode including the surrogate range. A lone \ud800 is a
perfectly valid Python str but has no UTF-8 encoding, so pa.array raises while building
the example
— the failure happens in the generator, before pgpq is involved at all, which is
why the traceback has nothing to do with encoding.

The strategy already excluded \x00 (Postgres rejects it in text); this adds the surrogate
category Cs next to it, with the reasoning recorded inline.

Found while cutting 0.12.0 — it reproduces on plain main, so it has been an occasional
unexplained CI failure waiting to happen. Verified with 8 random hypothesis seeds after the fix,
all green, plus the full Python suite (25 passed) against a real Postgres.

`test_roundtrip_arbitrary_primitive_tables` failed at random with

    UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800'
    while generating 'table' from _mixed_tables()

`st.text()` draws from all of Unicode including the surrogate range, and a lone
`\ud800` is a valid Python `str` with no UTF-8 encoding — so `pa.array` raised
while *building* the example, before pgpq saw anything. Excluding category `Cs`
alongside the `\x00` that was already excluded fixes it.

Found while cutting 0.12.0: this reproduces on plain `main`, and would show up in
CI as an occasional unexplained failure. Ran 8 random hypothesis seeds after the
fix, all green.
@adriangb
adriangb enabled auto-merge (squash) August 15, 2026 05:03
@adriangb
adriangb merged commit a2fbfd4 into main Aug 15, 2026
27 checks passed
@adriangb
adriangb deleted the claude/fix-surrogate-flake branch August 15, 2026 05:09
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.

1 participant