Skip to content

fix: read GuidSet elements with PostgreSQL's uuid_in grammar - #162

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
fix/uuid-in-grammar
Oct 18, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
fix/uuid-in-grammar

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #78
Closes #129

Problem

GuidSet.ParseValue called Guid.Parse, which reads the N, D, B, P and X formats and trims every Unicode whitespace. PostgreSQL's uuid_in reads 32 hex digits with a hyphen allowed after any group of four, optionally in braces, and nothing else. So a consumer saw:

  • GuidSet.Parse("{(6f9619ff-8b86-d011-b42d-00c04fc964ff)}") and GuidSet.Parse("{\" 6f9619ff-…\"}") parse in memory, then fail on the server as a literal (invalid input syntax for type uuid).
  • GuidSet.Parse("{6f96-19ff-8b86-d011-b42d-00c0-4fc9-64ff}") throw FormatException, where the server reads it.

The same grammar sat at three sites: GuidSet.ParseValue, GuidSet<T>.ParseValue (which handed the raw text to the element's Parse, Guid.Parse again for a generated wrapper) and the EF bridge for GuidSet<>, which called Guid.Parse directly (the clone sweep's waiver named it as #129's third site).

Change

Tests

  • SetParseFormatTests: GuidElement_ReadsEverySpellingUuidInReads (7 spellings, GuidSet and GuidSet<TestId>), GuidElement_RefusesWhatUuidInRefuses (12 texts: P, X, whitespace at either end including a no-break space, a hyphen after two digits or after the last group, an unclosed brace, 31 and 33 digits, urn:uuid:, empty), GuidElement_WritesTheDForm.
  • Oracles: SetElementWhiteSpaceContractTests and LiteralGrammarParityTests now hold their Guid rows; LiteralCorpusProbeTests (postgres:17 via Testcontainers) passes on GuidSet and GuidSet<TenantId> for the whitespace, parentheses and hyphen groups families.
  • Fix reverted (GuidSet.cs, SetTypeRegistry.cs, LiteralWhiteSpace.cs from the parent commit, UuidLiteral.cs deleted, tests kept): 15 rows of GuidElement_* fail, and SetElementWhiteSpaceContractTests reports GuidSet: accepts whitespace uuid_in rejects through Parse, TryParse and the TypeConverter. Restored afterwards.
  • Full runs: core 104 (SetParseFormatTests), conventions 324, EF translation 245, NodaTime 196, EF NodaTime 81, AspNetCore 84, integration (LiteralCorpusProbeTests, LiteralGrammarParityTests, WrapperArityIntegrationTests, SetIntegrationTests) 78 — all green. dotnet run tools/oracles.cs clones: 62 waived, 0 unwaived, 0 stale.

🤖 Generated with Claude Code

GuidSet.ParseValue called Guid.Parse, which reads the N, D, B, P and X
formats and trims every Unicode whitespace, while uuid_in reads 32 hex
digits with a hyphen allowed after any group of four, optionally in
braces, and nothing else. So {(6f9619ff-…)} and {" 6f9619ff-…"} parsed
in memory and failed on the server as a literal, and {6f96-19ff-…},
which the server reads, threw. GuidSet<T> handed the raw text to the
element's Parse — Guid.Parse again for a generated wrapper — and the EF
bridge for GuidSet<> called Guid.Parse directly, so the grammar had
three sites.

UuidLiteral is the one grammar now: GuidSet.ParseValue reads it,
GuidSet<T>.ParseValue reads it first and hands the element the D form,
as the numeric arities do, and the bridge goes through
GuidSet.ParseValue. Measured on PostgreSQL 17 (string_to_uuid in
uuid.c). The whitespace row of SetWrapperParityTests under #141 is gone
with it, since the wrapper's JSON element reader now refuses the padded
uuid as the primitive does; the rest of #141 is the numeric arities.

Closes #78
Closes #129

Found-By: OT
Defect-Class: LIT

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working breaking Changes an answer or a signature — needs a major found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) area/value-sets Value set families and wrapper arities package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference labels Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 6f0ea42 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/uuid-in-grammar branch October 18, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting area/value-sets Value set families and wrapper arities breaking Changes an answer or a signature — needs a major bug Something isn't working found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL severity/low Cosmetic, message or documentation-level difference

Projects

None yet

1 participant