Skip to content

fix(postgrest): stop duplicating the package id in X-Client-Info - #418

Merged
Tr00d merged 1 commit into
masterfrom
fix/postgrest-x-client-info-duplicate-prefix
Sep 8, 2026
Merged

fix(postgrest): stop duplicating the package id in X-Client-Info#418
Tr00d merged 1 commit into
masterfrom
fix/postgrest-x-client-info-duplicate-prefix

Conversation

@grdsdev

@grdsdev grdsdev commented Sep 7, 2026

Copy link
Copy Markdown
Member

Problem

Helpers.PrepareRequestHeaders prefixed the shared header helper with a literal postgrest-csharp/:

headers.Add("X-Client-Info", $"postgrest-csharp/{Util.GetAssemblyVersion(typeof(Client))}");

Util.GetAssemblyVersion (Core/Util.cs:33) already returns {assemblyname-lowercased}-csharp/{version}{metadata}. The emitted header was therefore:

postgrest-csharp/supabase.postgrest-csharp/8.0.0

The package id appears twice, and the value has three /-delimited segments instead of two. Any consumer that splits on / reads the version slot as supabase.postgrest-csharp.

Scope

Postgrest was the only outlier. The other five call sites pass the helper through unmodified and are correct:

  • Storage/StorageBucketApi.cs:39
  • Gotrue/Api.cs:43
  • Functions/Client.cs:180
  • Realtime/RealtimeSocket.cs:84
  • Supabase/Client.cs:296, Supabase/StatelessClient.cs:167

So the fix belongs in Postgrest, not in Util.

Change

  • Drop the redundant prefix; pass Util.GetAssemblyVersion(typeof(Client)) through as-is.
  • Fallback path (used when the version can't be resolved, e.g. Unity Editor / IL2CPP) keeps a package identifier but no longer duplicates it: supabase.postgrest-csharp/session-{AppSession}.
  • RequestHeaderTests.cs:62 asserted StartWith("postgrest-csharp/"). That passed only because of the bug — the assembly name is Supabase.Postgrest, so the corrected header starts with supabase.postgrest-csharp/. Updated to match, which mirrors Functions.Tests/ClientContractTests.cs:116 (supabase.functions-csharp/).

Impact

Confirmed against production telemetry (supabase-etl-prod-eu.dbt.supabase_client_lib_requests): this is the largest C# request bucket, roughly 648M requests/30d on v4 plus 31k on v8.

Open item: downstream telemetry parsing

The header shape changes for every Postgrest request once this ships, so the dbt mart likely needs a compensating change:

  • New rows emit two segments: supabase.postgrest-csharp/8.x.x.
  • Historical rows (the ~648M/30d bucket) emit three: postgrest-csharp/supabase.postgrest-csharp/4.x.x.

If the mart splits on / and takes index 1 as the version, it will keep mis-parsing history and start parsing new rows correctly — so a period of mixed shapes needs handling either way. A parser that takes the last /-delimited segment as the version, or that strips a leading postgrest-csharp/ when a second -csharp/ segment follows, handles both.

I could not verify the actual model: the only accessible dbt repo (supabase/dbt) is private and archived since 2023, and does not contain a supabase_client_lib_requests model. Someone with access to the live mart should confirm before this is released.

Testing

Not run locally — no .NET SDK on this machine. CI covers Postgrest.Tests.

Util.GetAssemblyVersion already returns "{assembly}-csharp/{version}{metadata}",
so prefixing it with "postgrest-csharp/" emitted
"postgrest-csharp/supabase.postgrest-csharp/8.0.0" - three /-delimited
segments instead of two, with the package id twice. Consumers that split on
'/' read "supabase.postgrest-csharp" as the version.

Postgrest was the only call site doing this; the other five pass the helper
through unmodified. Align the fallback shape too, and update the test that
only passed because of the bug.
@grdsdev
grdsdev requested a review from Tr00d September 7, 2026 14:56
@Tr00d
Tr00d merged commit 6c734dc into master Sep 8, 2026
1 check passed
@Tr00d
Tr00d deleted the fix/postgrest-x-client-info-duplicate-prefix branch September 8, 2026 11:58
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