---
title: "SW03002: Identifier generator failed"
description: "A custom naming function threw an error or returned an invalid name."
image: "https://stillwind.dev/og.png"
---

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

# SW03002: Identifier generator failed

This error occurs when a custom `naming` function fails while it generates a
name. The message shows which kind of name it was generating and the error from
the function. The compiler does not invent a name in its place.

## Reported

**stillwind.config.ts**

```ts
import { defineConfig } from "stillwind/config";

export default defineConfig({
  projects: [
    {
      css: "./src/stillwind.css",
      files: ["src/**/*.tsx"],
      namingRevision: "1",
      naming: {
        utilityClass(context, hash) {
          if (!context.module.endsWith("Button.tsx")) {
            throw new Error("Only Button.tsx is supported");
          }
          return `button_${hash.toString("hex")}`;
        },
      },
    },
  ],
});
```

```tsx
style("p-4");
```

> SW03002: identifier generation failed for class: Error: Only Button.tsx is supported

## Fixed

```ts title="stillwind.config.ts"
import { defineConfig } from "stillwind/config";

export default defineConfig({
  projects: [
    {
      css: "./src/stillwind.css",
      files: ["src/**/*.tsx"],
      namingRevision: "2",
      naming: {
        utilityClass(context, hash) {
          if (!context.module.endsWith("Button.tsx")) {
            return null;
          }
          return `button_${hash.toString("hex")}`;
        },
      },
    },
  ],
});
```

```tsx
style("p-4");
```

The custom name still applies to `Button.tsx`. Other modules use default names.

## How to fix

- Reproduce the request from the message, and fix the function so that it returns
  a name or `null` to keep the default name.
- Keep the function pure: the same request must always produce the same name.
- Change `namingRevision` whenever you change the function.

Source: https://stillwind.dev/docs/errors/SW03002/index.mdx
