---
title: "context-key-type"
description: "Detect unsafe context.WithValue key types."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# context-key-type

**Default severity:** `warning`

Context keys must be comparable and should use a dedicated named type to avoid
collisions between packages. Built-in types and anonymous empty structs risk
collisions; non-comparable and nil keys panic at runtime.

This type-aware check supersedes the earlier syntax-only implementation.

## Bad

```go
ctx = context.WithValue(ctx, "request-id", value)
```

## Good

```go
type contextKey struct{}
ctx = context.WithValue(ctx, contextKey{}, value)
```

Source: https://strider.gempir.com/analyzers/context-key-type/index.mdx
