Skip to content

GuidSet accepts whitespace inside an element that PostgreSQL's uuid_in rejects #78

Closed

Description

@CaffeinatedCoder

GuidSet accepts whitespace inside an element that PostgreSQL's uuid_in rejects.

GuidSet.Parse("{\" 6f9619ff-8b86-d011-b42d-00cf4fc964ff\"}", null);       // parses
GuidSet.Parse("{\\ 6f9619ff-8b86-d011-b42d-00cf4fc964ff}", null);        // parses
GuidSet.Parse("{ 6f9619ff-8b86-d011-b42d-00cf4fc964ff}", null);     // parses, even bare
SELECT '{" 6f9619ff-8b86-d011-b42d-00cf4fc964ff"}'::uuid[];  -- invalid input syntax for type uuid
SELECT '{ 6f9619ff-8b86-d011-b42d-00cf4fc964ff}'::uuid[];    -- fine: array_in drops bare ASCII whitespace

This was measured on PostgreSQL 17 while fixing #70; the table is in the comment there. GuidSet.ParseValue calls Guid.Parse, which trims all Unicode whitespace. uuid_in trims none. Bare ASCII whitespace is fine, because array_in drops it before uuid_in sees the element. A no-break space isn't ASCII, so array_in keeps it and uuid_in rejects it.

The library doesn't return a wrong value here. It parses text that PostgreSQL rejects, so {" …"} parses in memory and then fails when it reaches the database as a literal. Fixing it means rejecting input that parses today, so it belongs in 10.0.0, not a minor. It should also cover GuidSet<T>, which parses as Guid first.

Activity

  1. added this to the 10.0.0 milestone on Oct 17, 2026
  2. added
    bugSomething isn't working
    breakingChanges an answer or a signature — needs a major
    area/value-setsValue set families and wrapper arities
    on Oct 17, 2026
  3. added
    area/literalsParse, TryParse and formatting
    package/coreAffects CodoMetis.ValueRanges
    severity/lowCosmetic, message or documentation-level difference
    on Oct 17, 2026
  4. CaffeinatedCoder commented on Oct 17, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Oracle check (main at 3ecfa10): Would be caught today (retroactive; it was found while fixing #70, not by an oracle) by SetElementWhiteSpaceContractTests and LiteralGrammarParityTests. The failing rows: SetElementWhiteSpaceContractTests (rows GuidSet: accepts whitespace uuid_in rejects and GuidSet<TenantId>: …, through Parse, TryParse, TypeConverter and JSON) and LiteralGrammarParityTests (ElementWhitespace_ReadsAsPostgresReadsIt, row uuid[] GuidSet ).
    Verified by a run on 3ecfa10, where the defect is unfixed. 162 lines report SKIPPED [known candidate: Guid.Parse trims whitespace uuid_in rejects, #78] from candidates.json, and they will fail as candidate fixed once the fix lands.

  5. CaffeinatedCoder commented on Oct 17, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Would be caught today by LiteralCorpusProbeTests (#135), alongside SetElementWhiteSpaceContractTests and LiteralGrammarParityTests, which found it. Row: GuidSet whitespace {00000000-0000-0000-0000-000000000001 } (and {" …"}, {\ …}): library reads the uuid, PostgreSQL refuses. The same holds for GuidSet<TenantId>. Verified against postgres:17 on main + #135, where the defect is still present. The proof is the candidates.json rows GuidSet whitespace / GuidSet<TenantId> whitespace → #78. The related Guid.Parse grammar cells (the (…) form accepted, hyphen groups refused) are #129.

  6. CaffeinatedCoder commented on Oct 18, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed in #162 (with #129, one change): GuidSet.ParseValue reads uuid_in's grammar through the new UuidLiteral, so whitespace inside a quoted or escaped element is refused (FormatException) through Parse, TryParse, the TypeConverter and JSON, for GuidSet and GuidSet<T> alike; bare ASCII whitespace around an element is still dropped by the array grammar, as array_in drops it. SetElementWhiteSpaceContractTests, LiteralGrammarParityTests and LiteralCorpusProbeTests hold their Guid rows without candidates. Proven by reverting the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/literalsParse, TryParse and formattingarea/value-setsValue set families and wrapper aritiesbreakingChanges an answer or a signature — needs a majorbugSomething isn't workingfound-by/oracleFound by the generated-oracle machinery (claims × API surfaces)package/coreAffects CodoMetis.ValueRangesseverity/lowCosmetic, message or documentation-level difference

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions