Repository navigation
test: cover server SDK User-Agent contract - #295
Merged
Merged
Conversation
Contributor
posthog-dotnet Compliance ReportDate: 2026-08-18 20:46:26 UTC ✅ All Tests Passed!17/17 tests passed Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
|
Reviews (1): Last reviewed commit: "test: cover server SDK User-Agent contra..." | Re-trigger Greptile |
arnohillen
approved these changes
Aug 19, 2026
arnohillen
left a comment
There was a problem hiding this comment.
(created by PostHog Desktop)
The asserted shape matches production exactly (PostHogApiClient.cs:49 sends posthog-dotnet/{Version} ({Framework}; {OS}; {Arch}), which HttpClient parses into precisely the two ProductInfoHeaderValue entries the helper checks). The negative tests fail for the intended reason rather than by accident: 2.13.3-unexpected is a valid HTTP token and (; os; arch) a valid comment, so neither throws a FormatException that would mask the XunitException.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
The server SDK wire snapshots validate request JSON, but did not protect the accompanying
User-Agentheader contract. This adds coverage that every snapshotted request sends the expectedposthog-dotnet/<version>product and runtime comment containing the framework, OS, and process architecture.The contract compares the product version with the generated
VersionConstants.Versionvalue rather than a literal version, so release version bumps are covered without causing test churn. Negative tests prove that unexpected product/version values and missing runtime components are rejected.💚 How did you test it?
dotnet test tests/UnitTests/UnitTests.csproj --framework net8.0 --filter 'FullyQualifiedName~ServerSdkSnapshotTests.FinalWireSnapshots|FullyQualifiedName~ServerSdkSnapshotTests.UserAgentContractTests' --no-restore— passed 9/9 tests.dotnet format tests/UnitTests/UnitTests.csproj --verify-no-changes --no-restore— passed (workspace-load warnings only).netcoreapp3.1focused command built the projects successfully, but test execution is unavailable on this local Apple Silicon host because VSTest requests an x64dotnethost that is not installed. CI remains responsible for executing that target.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
A human directed the User-Agent contract hardening and PR submission. The Pi coding agent inspected the existing test-only diff, reran focused validation, and submitted it without adding release metadata; the independent final review supplied by the human reported no blockers. No shareable agent-session link is available.