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

# Handling EdgeSpark errors autonomously

> How to read and fix type errors, migration issues, build failures, SQL validation rejections, and runtime errors in EdgeSpark.

Most errors in EdgeSpark have a clear cause and a clear fix. This page explains what each error means and how to resolve it without stopping for human input.

## Type errors

**Symptom:** `edgespark deploy` or `tsc` fails during type checking.

**Cause:** Code references a table, bucket, var, secret, or runtime import that does not match the repo-owned defs or generated SDK types.

**Fix:**

```bash theme={null}
edgespark pull types
cd server && npx tsc --noEmit
```

If the problem is schema-related, confirm that `server/src/defs/db_schema.ts`, `server/src/defs/storage_schema.ts`, and `server/src/defs/runtime.ts` match the code you wrote.

## Migration errors

**Symptom:** Schema changes are not reflected in the database or deploy fails around migrations.

**Fix:**

```bash theme={null}
edgespark db generate
edgespark db check
edgespark db migrate
```

If destructive SQL is intentional, rerun with:

```bash theme={null}
edgespark db migrate --confirm-dangerous
```

## Build errors

**Symptom:** `edgespark deploy` fails at the build step.

### Missing default app export

**Fix:** Ensure `server/src/index.ts` exports a default Hono app:

```typescript server/src/index.ts theme={null}
import { Hono } from "hono";

const app = new Hono();

export default app;
```

### Route outside `/api/*`

If deploy reports a route outside `/api/*`, move it under `/api/*`, `/api/public/*`, or `/api/webhooks/*`.

### Bundle too large

Check for large dependencies or large static assets. See [platform limits](/reference/limits).

## SQL validation rejections

**Symptom:** A request fails at runtime after a successful deploy.

Common cases:

| Code you wrote                     | What was blocked           | Fix                                                          |
| ---------------------------------- | -------------------------- | ------------------------------------------------------------ |
| `DELETE FROM posts` with no filter | Destructive DML            | Add a `WHERE` clause or use `--confirm-dangerous` in CLI SQL |
| `DROP TABLE posts`                 | DDL at runtime             | Use `edgespark db generate` and `edgespark db migrate`       |
| `db.transaction(...)`              | Transactions not supported | Use `db.batch([...])`                                        |
| `PRAGMA ...`                       | Unsupported runtime SQL    | Remove it from app code                                      |

Check the exact rejection with:

```bash theme={null}
edgespark log tail
```

## Runtime null errors

**Symptom:** A handler throws because a row or file does not exist.

**Fix:**

```typescript theme={null}
const [post] = await db.select().from(posts).where(eq(posts.id, id));
if (!post) return c.json({ error: "Not found" }, 404);
```

```typescript theme={null}
const object = await storage.from(buckets.uploads).get(path);
if (!object) return c.json({ error: "File not found" }, 404);
```

## Stale type warnings

**Symptom:** The CLI says local SDK types are stale.

**Fix:**

```bash theme={null}
edgespark pull types
```

To check without writing files:

```bash theme={null}
edgespark pull types --check
```

## When to stop and ask for human input

Stop and ask when:

* You need the user to complete `edgespark login`
* You need the user to set a secret value through the secure secret-entry flow
* The next fix is destructive, such as dropping schema or deleting existing data

## See also

<Columns cols={2}>
  <Card title="Declarative workflow" icon="database" href="/agents/declarative-workflow">
    How defs, migrations, pulled schema, and generated types fit together.
  </Card>

  <Card title="Minimal human input" icon="comment" href="/agents/when-to-ask">
    Which situations require stopping instead of fixing autonomously.
  </Card>
</Columns>
