Skip to content

test: preserve nil metadata values over fallback - #823

Open
renanmpimentel wants to merge 1 commit into
gorilla:mainfrom
renanmpimentel:test/metadata-nil-value
Open

renanmpimentel wants to merge 1 commit into
gorilla:mainfrom
renanmpimentel:test/metadata-nil-value

Conversation

@renanmpimentel

@renanmpimentel renanmpimentel commented Oct 22, 2026 •

Copy link
Copy Markdown

Why this test matters

A fallback based on value == nil would lose the distinction between a missing metadata key and a present key whose value is nil. The new test protects both cases.

Supertest audit method

I used the Supertest test-audit skill to probe whether the existing suite would catch a plausible violation of this contract. The regression was applied only in an isolated worktree. The regression proof records three executed states: the existing tests pass with that regression, the new assertion fails against the same regression, and the new test passes with the original production code restored. The published diff adds tests only.

Change and verification

Summary

Add a regression test for route metadata whose key is present with a nil value. The test checks that MetadataContains reports the key, GetMetadataValue returns nil without an error, and GetMetadataValueOr preserves nil instead of selecting the fallback. A missing key still uses the fallback.

Regression proof

In an isolated worktree, I changed GetMetadataValueOr to return the fallback when value == nil. The unchanged suite passed (go test ./...). With this test added, the suite failed on the present nil value assertion. Restoring production code passed the race-enabled suite.

Validation

  • go test -race ./...
  • go vet ./...
  • gofmt -l route_test.go (clean)

The PR changes only route_test.go.

Repository guidance

No contribution guide or PR template was present in the audited checkout. Race tests, vet, and formatting passed. The GitHub add-to-project administrative check fails with Bad credentials before exercising this diff.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant