aws / aws/smithy-go

transport/http: depends on equality of pointer to zero-sized objects

Open
#568 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
255
Forks
83
Avg merge
1d 6h
Merged PRs (30d)
7

Description

In `transport/http/identity_test.go`, `TestIdentity` compares the result from `resolver.GetIdentity` with `&auth.AnonymousIdentity{}`. That test is fragile, as the behavior of comparing pointers to zero-sized objects (which `auth.AnonymousIdentity` is) is not guaranteed (https://go.dev/ref/spec#Comparison_operators, bullet point 6).

This test, and presumably other clients of `auth.IdentityResolver`s, should use a type assertion instead of interface equality.

Replace
```
if expected != actual {
```
with
```
if _, ok := actual.(*auth.AnonymousIdentity); !ok {
```
(Or a sentinel *value* should be defined in `auth` instead of a sentinel *type*.)

We believe this test will fail in the upcoming go1.25 (~August 2025) because of optimizations that change the behavior of equality on pointer-to-zero-sized allocations.

Contributor guide

Open the contributing guide

Research direction

Start in transport/http/identity_test.go at TestIdentity and trace the resolver.GetIdentity result through the auth.IdentityResolver interface. Run the test before and after the change; done means the test checks the returned identity type without relying on equality between pointers to zero-sized objects, and any other identified clients use the same safe approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication, backend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.