
# Troubleshooting

Run any failing command again with `DEBUG=1` in front for the full stack trace.

## @fob/lib-worker not found in this worker repo

```text
@fob/lib-worker not found in this worker repo.
Expected: /home/dev/node_modules/@fob/lib-worker/src/index.js
Run "npm install" in your worker repo first.
```

fob-worker uses the lib-worker installed in the worker repo you're in. Either you're not in the repo's root folder (check the `Expected:` path), or you haven't run `npm install` there.

## Steps directory not found

```text
Error: Steps directory not found: /home/dev/src/steps
```

Run fob-worker from the worker repo's root, the folder that contains `src/steps/`.

## Unknown step

```text
Unknown step: IN1_02_report
Run "fob-worker steps list" to see available steps
```

- Check the slug with `fob-worker steps list`. It's the `slug` in `defineStep()`, not the file name.
- Look above the error for `[Worker] Failed to import …`. The step file didn't load: a syntax error, a missing import, or a `defineStep()` without `name` or `description`. The message says which.
- Built-in steps such as `lib-worker:move_files` can't be run with `steps run`.

## Invalid input config

```text
Error: [IN1_02_report] Invalid input config:
  - flagged: Invalid input: expected array, received undefined
```

The config doesn't match the step's `inputSchema`. Look at the `Resolved config` line just above:

- A value that's missing after resolving usually came from a `{{<slug>.<field>}}` template whose step output isn't in `temp/`. Run that step first.
- With `--empty`, every field without a default is missing.

## Invalid output

The value `execute` returned doesn't match `outputSchema`. The message lists the fields that don't match.

## Station not found locally

```text
Station not found locally: IN1
Run "fob-orc stations pull IN1" first
```

`--station` reads `.orchestrator/stations/`. Pull the station with fob-orc, or check the short code with `fob-worker lines list`.

## Step not found in station

The station's file doesn't list that step. The message lists the steps it does have.

## Scenario not found

```text
Scenario not found: nope
Available scenarios: two-invoices
```

Scenarios live in `.orchestrator/scenarios/<slug>/<name>.json`, and `--scenario` takes the name without `.json`.

## No lines found

fob-worker builds lines from the station files in `.orchestrator/stations/`. Pull them with `fob-orc stations pull --all`. A station file without a `line` field doesn't belong to any line.

## A workpiece is stuck in failed

```bash
fob-worker workpieces show <id>
cat temp/stations/<STATION>/failed/<id>/error.txt
```

`error.json` has the error with any extra properties your code attached. After fixing the cause, move the folder back to the station's `input` bin to retry. See [Workpieces and bins](/docs/workers/workpieces#failures-and-retries).

## pm2 not found

`fob-worker procs` uses pm2. Install it with `npm install -g pm2`.

## Doesn't look like a fob worker repo

`procs start` needs a folder whose `package.json` depends on `@fob/lib-worker` and has a `main` entry, as the template's does.

## Running directly, not under pm2

The worker was started with `npm start` or `node`, not with `procs start`. Stop it in its terminal or with `kill <pid>`; `procs` can only stop, restart and tail pm2 workers.

## The worker exits with missing environment variables

```text
[Worker] Missing required environment variables:
  - ORCHESTRATOR_API_KEY
  - ORCHESTRATOR_API_SECRET
  - WORKER_LOCATION
```

Fill them in `.env` in the worker repo. See [Configuration](/docs/workers/configuration#environment-variables).

## The worker logs "Poll failed" or "Poll error"

- `Poll error: fetch failed`: the worker can't reach `ORCHESTRATOR_URL`. Check the URL and your network.
- `Poll failed: 401`: the API key or secret is wrong, expired or revoked. `403`: the key doesn't have the permissions the worker needs. Create a new key in **Settings → API Keys**.
- A message that another worker already serves the location: two workers have the same `WORKER_LOCATION`. Stop one. See [One worker per location](/docs/workers/processes#one-worker-per-location).

## Unknown command

```text
Unknown command: bogus
```

Check the spelling with `fob-worker --help`, or `fob-worker <resource> --help` for actions. Commands for stations and lines on the Orchestrator (`pull`, `push`, `run`) are in fob-orc.

## Still stuck

[Open an issue on GitHub](https://github.com/finopsbricks/fob-worker/issues) with the command, its output (with `DEBUG=1`) and your fob-worker and lib-worker versions. Remove API keys and business data first.
