Skip to content

StringSet accepts a NUL character, which PostgreSQL text cannot hold #133

Closed

Description

@CaffeinatedCoder

StringSet (and StringSet<T>) accepts a NUL character in an element. PostgreSQL's text can't hold one, so the set parses and then fails when it reaches the database. Measured on main (3ecfa10) against PostgreSQL 17.10:

StringSet.Parse("{a\u0000b}", null).Count;   // 1
StringSet.From(["a\0b"]);                     // also accepted
SELECT chr(0);   -- ERROR: null character not permitted
-- a text[] parameter holding U+0000: invalid byte sequence for encoding "UTF8": 0x00

Found by LiteralCorpusProbeTests (#123), family NUL. Not a wrong value: the failure is loud, at save time, and away from where the text came in — the same class as #78 (text the server rejects parses in memory).

Authority. docs/serialization.md: the text is "the same text the server itself reads"; docs/value-sets.md maps StringSet to text[].

Fix (10.0.0). Refuse U+0000 in a string element on every construction path (Parse, TryParse, JSON, From), with a message naming the rule. Refusing input that parses today is breaking, so it goes in the major.

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
    found-by/oracleFound by the generated-oracle machinery (claims × API surfaces)
    area/value-setsValue set families and wrapper arities
    area/literalsParse, TryParse and formatting
    package/coreAffects CodoMetis.ValueRanges
    severity/lowCosmetic, message or documentation-level difference
    on Oct 17, 2026
  3. CaffeinatedCoder commented on Oct 18, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed in #163 (stacked on #162): TextElement holds the rule once, and StringSet and StringSet<T> apply it on every construction path — From (both overloads) and Add/Contains/Remove throw ArgumentException, Parse, the TypeConverter and the EF JSON document throw FormatException, TryParse returns false, JSON throws JsonException — with a message naming NUL. Every other character stays text. LiteralCorpusProbeTests holds the two NUL 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