# Angular: NG0955: The provided track expression resulted in duplicated keys for a given collection (@for)

**Code:** `NG0955` · **Category:** Angular · **Seen on:** Angular, TypeScript

In an `@for` block (or `trackBy`), two items produced the same tracking key, so Angular cannot match them to DOM nodes reliably.

## Meaning

`track` must return a unique, stable value per item (an id). Duplicate keys — or tracking by a non-unique field or `$index` of changing lists — make Angular reuse the wrong nodes, causing glitches and the NG0955 warning. A related warning NG0956 reports a full list re-creation when keys change.

## Common causes

- Tracking by a field that is not unique (name, category)
- Items really contain duplicate ids from the API
- `track $index` on a list that reorders or filters
- Generating new ids on every render (`Math.random()`)
- Merging two lists without deduplication

## Quick fix

1. Track by a unique id: `track item.id`
2. Deduplicate data before rendering
3. Avoid random or index-based keys on dynamic lists

## Detailed fix by platform

### Angular

1. `@for (u of users; track u.id) { ... }`
2. Check duplicates: `new Set(users.map(u => u.id)).size !== users.length`

## Code examples

### Unique keys

```html
@for (u of users; track u.id) {      <!-- u.id must be unique and stable -->
  <app-user-row [user]="u" />
} @empty {
  <p>No users</p>
}
```

## How to diagnose

1. **Key** — What does track return?
2. **Data** — Are ids unique in the response?
3. **List** — Does it reorder or refilter?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng0955-duplicate-track-keys)
