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

# Common Errors

> Solutions to common ubx errors.

## Compile Errors

### `required attribute "X" is missing`

A required field for the resource type is not set.

```
✗  stack.iac:3  required attribute "engine" is missing from unit "db" (aws_rds_instance)
```

**Fix:** Add the missing attribute. Run `ubx docs aws_rds_instance --list` to see required fields.

### `local.X is not declared in this file`

Referencing a `local` block that doesn't exist.

```
✗  stack.iac:5  local.missing is not declared in this file
```

**Fix:** Add `local "missing" { value = ... }` or fix the typo.

### `~data.X.Y references an undeclared data block`

```
✗  ~data.aws_vpc.missing references an undeclared data block; add: data "aws_vpc" "missing" { ... }
```

**Fix:** Add the `data` block or fix the reference.

### `policy "X" violated`

A `policy` block's condition evaluated to false for a `unit` block.

**Fix:** Either fix the resource attribute to satisfy the policy, or change `severity` to `"warn"` if it's not critical.

## Version Errors

### `ubx version constraint not satisfied`

```
✗  ubx version constraint not satisfied
   required: >= 1.0.0
   running:  0.9.0
```

**Fix:** `go install github.com/ubiquex/ubx@latest`

## AI Errors

### `AI features require an API key`

```
Error: ubx explain: AI features require an API key — set UBX_AI_API_KEY or configure ai.api_key in ubx.yaml
```

**Fix:** `export UBX_AI_API_KEY=sk-ant-...`

## State Errors

### `.ubx directory not found`

```
✗  ubx refresh: .ubx directory not found — run ubx apply at least once first
```

**Fix:** Run `ubx apply` first to create the `.ubx/` directory and initial state.

## TypeScript Compile Errors

### `npm error 404 Not Found @ubiquex/...`

A `component` block references a package that doesn't exist in the npm registry.

**Fix:** Check the `source` attribute is correct. Use `ubx validate --compile` to catch this earlier.

### `error TS1184: Modifiers cannot appear here`

Generated TypeScript has a module-level statement inside a block. This is a ubx bug — please [open an issue](https://github.com/ubiquex/ubx/issues).
