LAWDE Shield · Documentation

Troubleshooting: the @lawdeshield/agent SDK

Exact @lawdeshield/agent messages — “[LawdeAgent] apiKey is required”, “[LAWDE] LAWDE_API_KEY missing” — and what to check when errors never reach LAWDE.

Nothing arrives and nothing is printed

The agent never throws into your app and does not print LAWDE’s reply. When LAWDE refuses an error (a bad key, a limit), the agent keeps it in a small in-memory queue and moves on. To find the reason:

  1. Send one test error with cURL using the same key and app ID (see Getting started), or run npx @lawdeshield/cli init again. Both show LAWDE’s exact reply.
  2. Look the message up on this page or the API key, app and limits pages.
  3. Next.js: check that instrumentation.ts exports onRequestError. Without it, errors Next.js catches itself (a typical API 500) never reach the agent.
  4. Check LAWDE_API_KEY is set where the app runs, not only in your local env file.

Messages

[LawdeAgent] apiKey is required

Where: Thrown by new LawdeAgent(...)

What it means: new LawdeAgent() was called with an empty apiKey, usually because process.env.LAWDE_API_KEY is not set where the code runs.

Fix:

  • Set LAWDE_API_KEY in that environment, or guard the constructor so the app starts without LAWDE when the key is missing.

[LAWDE] LAWDE_API_KEY missing — live crash capture disabled

Where: Server log at startup (Next.js instrumentation.ts)

What it means: The Next.js server started without LAWDE_API_KEY, so the agent was not created and no errors are sent.

Fix:

  • Add LAWDE_API_KEY to the environment of that deployment (on Vercel: vercel env add LAWDE_API_KEY production) and redeploy.

[LAWDE] LAWDE_API_KEY missing — crash capture disabled

Where: Server log at startup (Medusa initLawde)

What it means: initLawde() found no LAWDE_API_KEY, so it sent nothing.

Fix:

  • Set LAWDE_API_KEY on every Medusa host, then restart.

[LawdeAgent] captureException failed

Where: Server log, only with debug: true

What it means: Building or sending the report threw. The agent never throws into your app; with debug: true it logs the cause next to this line.

Fix:

  • Read the error printed after it. Turn debug off again once fixed.