# LAWDE Shield documentation (full text) > Production found the bug. LAWDE tells you if the fix held. Error monitoring for Node.js and Next.js teams that follows each crash from fix, to merge, to release, to production — then gives an honest verdict: Resolved, Recurred, or not enough evidence yet. Fix verification is in beta. Privacy: LAWDE does not store customer source code as a durable copy. Secrets are scrubbed at the edge. Beacon uses read-only GitHub access for short-lived diagnosis context. Index: https://www.lawde.net/llms.txt Pages in this file (each is also available as Markdown at the same URL plus .md): - Getting started: from signup to your first diagnosed crash: https://www.lawde.net/docs/getting-started (https://www.lawde.net/docs/getting-started.md) - Troubleshooting: https://www.lawde.net/docs/troubleshooting (https://www.lawde.net/docs/troubleshooting.md) - Troubleshooting: API key errors: https://www.lawde.net/docs/troubleshooting/api-keys (https://www.lawde.net/docs/troubleshooting/api-keys.md) - Troubleshooting: app errors: https://www.lawde.net/docs/troubleshooting/apps (https://www.lawde.net/docs/troubleshooting/apps.md) - Troubleshooting: rate limits and quotas: https://www.lawde.net/docs/troubleshooting/limits (https://www.lawde.net/docs/troubleshooting/limits.md) - Troubleshooting: request and server errors: https://www.lawde.net/docs/troubleshooting/payloads (https://www.lawde.net/docs/troubleshooting/payloads.md) - Troubleshooting: npx @lawdeshield/cli init: https://www.lawde.net/docs/troubleshooting/cli (https://www.lawde.net/docs/troubleshooting/cli.md) - Troubleshooting: the @lawdeshield/agent SDK: https://www.lawde.net/docs/troubleshooting/agent (https://www.lawde.net/docs/troubleshooting/agent.md) Other docs pages (HTML only, not included below): - Documentation overview: https://www.lawde.net/docs - Guided tour (quickstart): https://www.lawde.net/docs/quickstart - Setup guide: API keys and .env: https://www.lawde.net/docs/setup - JavaScript / TypeScript SDK (Next.js, Express, Fastify, Koa, NestJS, Medusa): https://www.lawde.net/docs/sdk/javascript - Python (HTTP client): https://www.lawde.net/docs/sdk/python - HTTP / cURL ingest contract: https://www.lawde.net/docs/sdk/http - Core engines: https://www.lawde.net/docs/engines - Pricing tiers: https://www.lawde.net/docs/tiers - .lawdeignore restricted paths: https://www.lawde.net/docs/lawdeignore - Custom scrubbers: https://www.lawde.net/docs/scrubbers - Audit logs: https://www.lawde.net/docs/audit-logs - Explore: https://www.lawde.net/docs/explore - Enterprise setup: https://www.lawde.net/docs/enterprise --- # Getting started: from signup to your first diagnosed crash > Set up LAWDE Shield end to end: sign up, run npx @lawdeshield/cli init (or install @lawdeshield/agent by hand for Next.js, Express, Medusa or raw HTTP), see your first event, run a diagnosis and connect GitHub. Source: https://www.lawde.net/docs/getting-started This is the whole path in one page. LAWDE does not pull crashes from your servers: your app sends them. Quick setup does the wiring for you; the manual path shows the same code if you would rather write it yourself. If a step fails, the exact message and its fix are in [Troubleshooting](https://www.lawde.net/docs/troubleshooting). ## 1. Sign up Create an account at [lawde.net/signup](https://www.lawde.net/signup) with GitHub or Google. Your first login creates a Hobby workspace; nothing appears on the dashboard until your app sends an error. Errors belong to an app inside the workspace. If the workspace has no app yet, create one on [Apps](https://www.lawde.net/apps) first: browser sign-in in the next step asks which app the new key is for. ## 2. Quick setup: npx @lawdeshield/cli init Run `npx @lawdeshield/cli init` in your app’s folder. It works with Next.js, Express, Node servers and Medusa v2, shows every file change as a diff before writing it, and asks before each one. Terminal: ```bash # In your app's folder (Next.js, Express, Node or Medusa v2) npx @lawdeshield/cli init # Preview every change without writing, installing or sending anything npx @lawdeshield/cli init --dry-run ``` What the command does, in order: 1. Prints what it will send: one test error at the end (skip it with `--no-test`), which counts as 1 error toward today’s quota. The CLI sends no file names, paths or code. 2. Detects the framework (Next.js, Express, Medusa v2 or a Node entry file), TypeScript or JavaScript, and your package manager. In a monorepo it asks which package to set up. 3. Gets a key. It uses `--key`, `LAWDE_API_KEY`, or a key already in your env file. Otherwise it shows a code and opens lawde.net: you sign in, check the code matches, pick the app, and approve. LAWDE then creates a new key for that one app. The code expires in 10 minutes and works once. Use `--paste` to paste a key instead, or `--no-browser` to print the link. 4. Installs `@lawdeshield/agent` with your package manager, after asking. 5. Shows each file change as a diff and asks before writing it. Next.js: `instrumentation.ts` with `register()` and `onRequestError`. Express or Node: a new `lawde.js` (or `lawde.ts`) loaded first from your entry file; the Express error handler is printed for you to add after your routes. Medusa v2: `instrumentation.ts` and `src/api/middlewares.ts`. A file that already has its own code is not edited; the CLI prints what to add instead. 6. Writes `LAWDE_API_KEY` (and `LAWDE_APP_ID` when known) to `.env.local` for Next.js or `.env` otherwise, and adds that file to `.gitignore` if git does not ignore it yet. 7. Reminds you that the env file is not deployed. On Vercel it prints `vercel env add LAWDE_API_KEY production`; the CLI never runs it for you. 8. Sends one test error. It prints ✓ only when LAWDE’s response confirms the error was stored, with a link to it. Anything else prints ✗ with the reason. > **What ✓ means.** ✓ checks your key and app. It does not show that your app reports its own errors: that starts once your app runs with the new code. The test error is tagged as a CLI test, so it never counts as your app’s first real event. Options: ```text --dry-run Show every change as a diff; write, install and send nothing -y, --yes Accept every change (for scripts and CI) --key API key (or set LAWDE_API_KEY). Without one you approve in the browser --paste Paste a key instead of approving in the browser --no-browser Print the approval link instead of opening it --app App ID (or set LAWDE_APP_ID). Browser sign-in sets it for you --cwd Project folder (default: current folder) --entry Server entry file for Express / Node, when it can't be detected --no-install Don't install @lawdeshield/agent --no-test Don't send the test error ``` ## 3. Or set it up by hand Install the agent, copy a key from [Settings → API keys](https://www.lawde.net/settings/api-keys) (the full value is shown once), and put it in your server environment. Keep the key server-side. Install: ```bash npm install @lawdeshield/agent ``` .env: ```bash LAWDE_API_KEY=lawde_... # from Settings → API keys (shown once) LAWDE_APP_ID=... # optional: the app this key reports to ``` ## Next.js (App Router): instrumentation.ts Next.js catches errors from Route Handlers, Server Components, Server Actions and proxy itself, so they never reach `uncaughtException`. The `onRequestError` hook (Next.js 15+) hands them to LAWDE. Without it, a typical API 500 never reaches LAWDE. instrumentation.ts: ```ts // File: instrumentation.ts (project root, or src/ if you use a src directory) import type { Instrumentation } from 'next'; import type { LawdeAgent } from '@lawdeshield/agent'; let agent: LawdeAgent | undefined; export async function register() { // Runs once when the Next.js server process boots (Node runtime only) if (process.env.NEXT_RUNTIME !== 'nodejs') return; if (!process.env.LAWDE_API_KEY) { console.warn('[LAWDE] LAWDE_API_KEY missing — live crash capture disabled'); return; } const { LawdeAgent } = await import('@lawdeshield/agent'); agent = new LawdeAgent({ apiKey: process.env.LAWDE_API_KEY, appId: process.env.LAWDE_APP_ID, // release + environment resolve from LAWDE_RELEASE / LAWDE_ENVIRONMENT, // then Vercel's VERCEL_GIT_COMMIT_SHA / VERCEL_ENV automatically. }); } // Next.js catches Route Handler, Server Component, Server Action and proxy errors itself, so // they never reach process 'uncaughtException'. This hook (Next.js 15+) hands them to LAWDE. // routePath is the route file pattern (e.g. /app/api/orders/[id]/route), never the real URL. export const onRequestError: Instrumentation.onRequestError = async (err, request, context) => { await agent?.captureException(err, { metadata: { route: context.routePath, route_type: context.routeType, method: request.method }, }); }; ``` More options, including source maps: [JavaScript / TypeScript SDK → Next.js](https://www.lawde.net/docs/sdk/javascript#nextjs). ## Express Create the agent before your app, and register its error handler after your routes. server.ts: ```ts import express from 'express'; import { LawdeAgent } from '@lawdeshield/agent'; const agent = new LawdeAgent({ apiKey: process.env.LAWDE_API_KEY! }); const app = express(); // ...your routes app.use(agent.expressErrorHandler()); // after your routes app.listen(3000); ``` Fastify, Koa and NestJS adapters: [JavaScript / TypeScript SDK](https://www.lawde.net/docs/sdk/javascript#express). ## Medusa v2 instrumentation.ts: ```ts // instrumentation.ts (project root, next to medusa-config.ts) // `medusa start` runs register() once in every process, including cluster workers. import { initLawde } from '@lawdeshield/agent/medusa'; export function register() { // Reads LAWDE_API_KEY and LAWDE_APP_ID. Without a key it logs a warning and sends nothing. initLawde(); } ``` src/api/middlewares.ts: ```ts // src/api/middlewares.ts import { defineMiddlewares, errorHandler } from '@medusajs/framework/http'; import { lawdeErrorHandler } from '@lawdeshield/agent/medusa'; export default defineMiddlewares({ // Reports 5xx errors to LAWDE (route pattern, method, status — never the real URL), // then Medusa's own handler sends the usual response. errorHandler: lawdeErrorHandler(errorHandler()), routes: [ // …your existing middleware routes stay here ], }); ``` Environment: ```bash # Every Medusa host (Medusa's server does not run on Vercel) LAWDE_API_KEY=lawde_live_… LAWDE_APP_ID=… # optional LAWDE_ENVIRONMENT=production # not needed on Railway: RAILWAY_ENVIRONMENT_NAME is read # Release (git SHA) is read automatically on Railway (RAILWAY_GIT_COMMIT_SHA) and # Render (RENDER_GIT_COMMIT). Elsewhere set LAWDE_RELEASE= at build/deploy time. # Without a known environment LAWDE cannot judge fixes for this app. ``` Subscribers, scheduled jobs and workflow steps: [JavaScript / TypeScript SDK → Medusa](https://www.lawde.net/docs/sdk/javascript#medusa). ## Any language: raw HTTP POST JSON to `/api/v1/logs/ingest` with your key in the `x-lawde-api-key` header (`Authorization: Bearer ` also works). Required fields: `error_class`, `error_message`, `stack_trace`, `file_path` and `line_number`. Optional: `column_number`, `commit_hash`, `environment`, `timestamp`, `metadata` and `app_id`. cURL: ```bash curl -X POST https://www.lawde.net/api/v1/logs/ingest \ -H "Content-Type: application/json" \ -H "x-lawde-api-key: $LAWDE_API_KEY" \ -d '{ "error_class": "TypeError", "error_message": "Cannot read property of null", "stack_trace": "TypeError: Cannot read property of null\n at handler (src/api/route.ts:42:11)", "file_path": "src/api/route.ts", "line_number": 42, "environment": "production" }' ``` A stored error answers HTTP 200 with `"success": true` and a `cluster_id`. Full contract: [HTTP / cURL](https://www.lawde.net/docs/sdk/http). ## 4. See your first event Throw an error in a real route of your running app, then open [Overview](https://www.lawde.net/dashboard) or Issues. Identical crashes group into one issue, and look-alikes join it when their similarity is at least 0.85. Secrets are scrubbed before the event is stored. Nothing showing? The agent does not print LAWDE’s reply, so send one test error with the cURL command above (or run `npx @lawdeshield/cli init` again) to see the exact message, then look it up in [Troubleshooting](https://www.lawde.net/docs/troubleshooting). ## 5. Connect GitHub Open [Profile → Connected Services](https://www.lawde.net/profile?tab=services), install the LAWDE AI GitHub App and pick the repository for this app. Access is read-only and limited to that installation. For one diagnosis, Beacon reads a short window of source around the crash line at the crashing release. That source is used for that diagnosis and dropped; LAWDE does not keep a copy. Paths listed in a root `.lawdeignore` are never fetched or sent to AI: see [.lawdeignore](https://www.lawde.net/docs/lawdeignore). ## 6. Run your first diagnosis Open the issue and click Diagnose. Athena explains what broke, why, and where to fix it. It runs only when you ask, when your app has sent a real event, when GitHub is connected, and when your daily AI quota has room. Aegis scores each diagnosis on evidence it checks itself, such as your code in the crash frame and the error on the crash line. A suggested patch is shown only when the diagnosis score is at least 0.70 and the patch applies to your source. Below that you see the diagnosis and its weak points, not a patch. A suggested patch is generated, not verified: review it like any other change. After a fix ships, Fix verification (beta) can follow it from the pull request to the release and report Resolved, Recurred or not enough evidence yet. See the [sample case](https://www.lawde.net/sample-case) (sample data). ## Frequently asked questions ### Does npx @lawdeshield/cli init change files without asking? No. It shows each change as a diff and asks before writing it. --dry-run writes, installs and sends nothing; --yes accepts every change for scripts and CI. ### What does the ✓ after the test error mean? LAWDE’s response confirmed it stored the test error. It checks your key and app; your own errors are reported once your app runs with the new code. ### Which frameworks does Quick setup support? Next.js, Express, Node servers with an entry file, and Medusa v2. For anything else, send errors to the HTTP ingest API. ### Does LAWDE store my source code? No. Source read from GitHub is used for one diagnosis and then dropped. LAWDE keeps the diagnosis result, not your code. --- # Troubleshooting > Find a LAWDE Shield error message and its fix: API keys, apps, rate limits and quotas, ingest requests, npx @lawdeshield/cli init and the @lawdeshield/agent SDK. Every message is quoted exactly. Source: https://www.lawde.net/docs/troubleshooting Search this page for the message you see (Ctrl+F or ⌘F). Each message is quoted exactly as LAWDE returns or prints it, with what it means and how to fix it. ## First, see the exact message The agent does not print LAWDE’s reply. Send one test error with cURL using your key (see [Getting started](https://www.lawde.net/docs/getting-started#http)), or run `npx @lawdeshield/cli init` again: it prints ✓ only when LAWDE confirms it stored the error, and ✗ with the reason otherwise. ## API keys Missing, invalid, revoked or dormant keys, and keys without ingest permission. [All api keys messages](https://www.lawde.net/docs/troubleshooting/api-keys). - [`Missing API key. Provide x-lawde-api-key or Authorization: Bearer .`](https://www.lawde.net/docs/troubleshooting/api-keys#missing-api-key) - [`Invalid or revoked API key.`](https://www.lawde.net/docs/troubleshooting/api-keys#invalid-or-revoked-api-key) - [`API key is dormant due to workspace plan limits. Upgrade your plan or activate this key in Settings.`](https://www.lawde.net/docs/troubleshooting/api-keys#key-dormant) - [`This API key does not have ingest permission.`](https://www.lawde.net/docs/troubleshooting/api-keys#no-ingest-permission) - [`Warning: this does not look like a LAWDE key (they start with lawde_). Continuing; the test error will tell.`](https://www.lawde.net/docs/troubleshooting/api-keys#not-a-lawde-key) ## Apps An app-scoped key used for another app, unknown app IDs, and paused apps. [All apps messages](https://www.lawde.net/docs/troubleshooting/apps). - [`This API key is for another app. Use that app’s ID, or a key for this app.`](https://www.lawde.net/docs/troubleshooting/apps#app-mismatch) - [`app_id does not belong to this workspace.`](https://www.lawde.net/docs/troubleshooting/apps#app-id-not-in-workspace) - [`No apps configured for this workspace. Create an app before ingesting.`](https://www.lawde.net/docs/troubleshooting/apps#no-apps) - [`App is dormant due to workspace plan limits. Upgrade your plan or activate this app in Settings.`](https://www.lawde.net/docs/troubleshooting/apps#app-dormant) ## Limits and quotas Burst rate limits, per-key limits, the workspace quota, billing holds and metering. [All limits and quotas messages](https://www.lawde.net/docs/troubleshooting/limits). - [`Rate limit exceeded`](https://www.lawde.net/docs/troubleshooting/limits#rate-limit-exceeded) - [`Rate limit exceeded`](https://www.lawde.net/docs/troubleshooting/limits#api-key-rate-limit) - [`This workspace has reached its errors/day limit for the plan (shared by all members). Quota resets at 00:00 UTC.`](https://www.lawde.net/docs/troubleshooting/limits#workspace-quota-exceeded) - [`Workspace access is suspended. Update payment to resume ingest.`](https://www.lawde.net/docs/troubleshooting/limits#payment-required) - [`Ingest metering unavailable`](https://www.lawde.net/docs/troubleshooting/limits#metering-unavailable) ## Requests Invalid JSON, missing or wrong fields, and errors on LAWDE’s side. [All requests messages](https://www.lawde.net/docs/troubleshooting/payloads). - [`Invalid JSON payload`](https://www.lawde.net/docs/troubleshooting/payloads#invalid-json) - [`Validation failed`](https://www.lawde.net/docs/troubleshooting/payloads#validation-failed) - [`error_class is required`](https://www.lawde.net/docs/troubleshooting/payloads#field-required) - [`line_number must be a positive integer`](https://www.lawde.net/docs/troubleshooting/payloads#line-number) - [`app_id must be a valid UUID`](https://www.lawde.net/docs/troubleshooting/payloads#app-id-uuid) - [`Failed to persist error log`](https://www.lawde.net/docs/troubleshooting/payloads#persist-failed) - [`Internal Sentinel Ingestion Error`](https://www.lawde.net/docs/troubleshooting/payloads#internal-error) ## CLI Browser sign-in codes, the approval page, project detection and the test error. [All cli messages](https://www.lawde.net/docs/troubleshooting/cli). - [`Browser sign-in did not finish: the code expired (10 minutes). Run npx @lawdeshield/cli init again.`](https://www.lawde.net/docs/troubleshooting/cli#code-expired) - [`Browser sign-in did not finish: the request was denied on lawde.net.`](https://www.lawde.net/docs/troubleshooting/cli#request-denied) - [`Browser sign-in did not finish: lost contact with .`](https://www.lawde.net/docs/troubleshooting/cli#lost-contact) - [`Browser sign-in did not finish: could not reach ().`](https://www.lawde.net/docs/troubleshooting/cli#could-not-reach) - [`Too many sign-in codes from this network. Try again in a few minutes.`](https://www.lawde.net/docs/troubleshooting/cli#too-many-codes) - [`Browser sign-in is not available right now. Paste a key instead (--paste).`](https://www.lawde.net/docs/troubleshooting/cli#sign-in-unavailable) - [`Unknown code. Run npx @lawdeshield/cli init again.`](https://www.lawde.net/docs/troubleshooting/cli#unknown-code) - [`This code was already used.`](https://www.lawde.net/docs/troubleshooting/cli#code-already-used) - [`This code cannot be used. Run npx @lawdeshield/cli init again.`](https://www.lawde.net/docs/troubleshooting/cli#code-cannot-be-used) - [`This code was not found, was already used, or expired. Run npx @lawdeshield/cli init again.`](https://www.lawde.net/docs/troubleshooting/cli#approve-not-found) - [`Only people who can manage API keys in this workspace can approve.`](https://www.lawde.net/docs/troubleshooting/cli#approve-forbidden) - [`Pick the app this key is for.`](https://www.lawde.net/docs/troubleshooting/cli#approve-app-required) - [`That app is paused by your plan limits. Activate it in Settings first.`](https://www.lawde.net/docs/troubleshooting/cli#approve-app-dormant) - [`Your plan allows active keys. Choose one to replace.`](https://www.lawde.net/docs/troubleshooting/cli#approve-key-limit) - [`No package.json in . Run this in your app's folder, or pass --cwd.`](https://www.lawde.net/docs/troubleshooting/cli#no-package-json) - [`Could not tell which framework this is (looked for Next.js, Express, Medusa v2 or a Node entry file). Run it in your app folder or pass --cwd ; for a Node server, pass --entry .`](https://www.lawde.net/docs/troubleshooting/cli#unknown-framework) - [`Several packages found. Run again with --cwd .`](https://www.lawde.net/docs/troubleshooting/cli#several-packages) - [`Could not find your server entry file. Run again with --entry , or create lawde.js yourself:`](https://www.lawde.net/docs/troubleshooting/cli#entry-not-found) - [`No API key. Pass --key or set LAWDE_API_KEY.`](https://www.lawde.net/docs/troubleshooting/cli#no-api-key) - [`--app must be an app ID (a UUID). Find it on the app page in the dashboard.`](https://www.lawde.net/docs/troubleshooting/cli#app-not-uuid) - [` failed (exit ). Nothing else was changed.`](https://www.lawde.net/docs/troubleshooting/cli#install-failed) - [`✗ LAWDE did not store the test error: `](https://www.lawde.net/docs/troubleshooting/cli#test-error-not-stored) - [`the API key was rejected ().`](https://www.lawde.net/docs/troubleshooting/cli#key-rejected) - [`a limit was reached ().`](https://www.lawde.net/docs/troubleshooting/cli#limit-reached) - [`LAWDE answered without confirming the error was stored.`](https://www.lawde.net/docs/troubleshooting/cli#not-confirmed) - [`✗ No API key, so no test error was sent.`](https://www.lawde.net/docs/troubleshooting/cli#no-key-no-test) ## Agent SDK Startup warnings, a missing key, and why nothing arrives. [All agent sdk messages](https://www.lawde.net/docs/troubleshooting/agent). - [`[LawdeAgent] apiKey is required`](/docs/troubleshooting/agent#apikey-required) - [`[LAWDE] LAWDE_API_KEY missing — live crash capture disabled`](/docs/troubleshooting/agent#key-missing-next) - [`[LAWDE] LAWDE_API_KEY missing — crash capture disabled`](/docs/troubleshooting/agent#key-missing-medusa) - [`[LawdeAgent] captureException failed`](/docs/troubleshooting/agent#capture-failed-debug) --- # Troubleshooting: API key errors > Exact LAWDE Shield API key error messages — “Missing API key”, “Invalid or revoked API key.”, KEY_DORMANT, no ingest permission — what each means and how to fix it. Source: https://www.lawde.net/docs/troubleshooting/api-keys Each message below is quoted exactly as LAWDE returns or prints it. The agent does not print LAWDE’s reply. To see it, send one test error with cURL (see [Getting started](https://www.lawde.net/docs/getting-started#http)) or run `npx @lawdeshield/cli init` again. ## Messages ### `Missing API key. Provide x-lawde-api-key or Authorization: Bearer .` - Where: Ingest API response (HTTP 401) - Code: `Unauthorized` - Message: `Missing API key. Provide x-lawde-api-key or Authorization: Bearer .` - What it means: The request reached LAWDE without a key. Usually `LAWDE_API_KEY` is set on your machine but not where the app runs. - Fix: - Send the key in the `x-lawde-api-key` header, or as `Authorization: Bearer `. - Set `LAWDE_API_KEY` in your host’s environment settings too: `.env` and `.env.local` are usually not deployed. On Vercel: `vercel env add LAWDE_API_KEY production`, then redeploy. ### `Invalid or revoked API key.` - Where: Ingest API response (HTTP 401) - Code: `Unauthorized` - Message: `Invalid or revoked API key.` - What it means: The key does not match an active key in any workspace: it was mistyped, cut short, revoked, or replaced. - Fix: - Check the value has no spaces or quotes around it. LAWDE keys start with `lawde_`. - Run `npx @lawdeshield/cli init` again, or create a key in [Settings → API keys](https://www.lawde.net/settings/api-keys). - Update the key wherever the app runs, then redeploy or restart. ### `API key is dormant due to workspace plan limits. Upgrade your plan or activate this key in Settings.` - Where: Ingest API response (HTTP 403) - Code: `KEY_DORMANT` - Message: `API key is dormant due to workspace plan limits. Upgrade your plan or activate this key in Settings.` - What it means: The workspace has more keys than its plan allows, and this key is one of the inactive ones. - Fix: - Activate this key in Settings, turning off another one if needed. - Or move to a plan with more keys: [Pricing](https://www.lawde.net/pricing). ### `This API key does not have ingest permission.` - Where: Ingest API response (HTTP 403) - Code: `FORBIDDEN` - Message: `This API key does not have ingest permission.` - What it means: The key is valid but is not allowed to send errors. - Fix: - Use a key that can ingest, or create one in [Settings → API keys](https://www.lawde.net/settings/api-keys). ### `Warning: this does not look like a LAWDE key (they start with lawde_). Continuing; the test error will tell.` - Where: npx @lawdeshield/cli init output (warning) - Message: `Warning: this does not look like a LAWDE key (they start with lawde_). Continuing; the test error will tell.` - What it means: The key you passed, pasted or had in your env file does not start with `lawde_`. The CLI keeps going and the test error shows whether LAWDE accepts it. - Fix: - If the test error then fails, copy the key again from [Settings → API keys](https://www.lawde.net/settings/api-keys), or drop `--key` and approve in the browser. --- # Troubleshooting: app errors > Exact LAWDE Shield app error messages — APP_MISMATCH (“This API key is for another app.”), App not found, APP_DORMANT — what each means and how to fix it. Source: https://www.lawde.net/docs/troubleshooting/apps Each message below is quoted exactly as LAWDE returns it. The agent does not print LAWDE’s reply. To see it, send one test error with cURL (see [Getting started](https://www.lawde.net/docs/getting-started#http)) or run `npx @lawdeshield/cli init` again. ## Messages ### `This API key is for another app. Use that app’s ID, or a key for this app.` - Where: Ingest API response (HTTP 403) - Code: `APP_MISMATCH` - Message: `This API key is for another app. Use that app’s ID, or a key for this app.` - What it means: The key belongs to one app (keys made by `npx @lawdeshield/cli init` browser sign-in always do), but the event names a different app in `app_id` (from `LAWDE_APP_ID` or the `appId` option). - Fix: - Set `LAWDE_APP_ID` to the app the key was made for. The CLI writes it next to the key. - Or use a key made for the app you want, for example by running `npx @lawdeshield/cli init` in that app and picking it on lawde.net. ### `app_id does not belong to this workspace.` - Where: Ingest API response (HTTP 404) - Code: `App not found` - Message: `app_id does not belong to this workspace.` - What it means: The `app_id` sent with the event is not an app in the key’s workspace. Often the ID comes from another workspace, or the app was deleted. - Fix: - Copy the app ID from the app’s page on [Apps](https://www.lawde.net/apps), or remove `LAWDE_APP_ID` so the event goes to the key’s own app (or, for a workspace-wide key, the first active app). ### `No apps configured for this workspace. Create an app before ingesting.` - Where: Ingest API response (HTTP 404) - Code: `App not found` - Message: `No apps configured for this workspace. Create an app before ingesting.` - What it means: The workspace has no apps, so the event has nowhere to go. - Fix: - Create an app on [Apps](https://www.lawde.net/apps), then send the error again. ### `App is dormant due to workspace plan limits. Upgrade your plan or activate this app in Settings.` - Where: Ingest API response (HTTP 403) - Code: `APP_DORMANT` - Message: `App is dormant due to workspace plan limits. Upgrade your plan or activate this app in Settings.` - What it means: The workspace has more apps than its plan allows, and this app is one of the paused ones. - Fix: - Activate the app in Settings (pausing another if needed), or move to a plan with more apps: [Pricing](https://www.lawde.net/pricing). --- # Troubleshooting: rate limits and quotas > Exact LAWDE Shield limit messages — “Rate limit exceeded”, WORKSPACE_QUOTA_EXCEEDED, “Payment required”, “Ingest metering unavailable” — what each means and how to fix it. Source: https://www.lawde.net/docs/troubleshooting/limits Each message below is quoted exactly as LAWDE returns it. Errors refused by a limit are not stored. The agent does not print LAWDE’s reply. To see it, send one test error with cURL (see [Getting started](https://www.lawde.net/docs/getting-started#http)) or run `npx @lawdeshield/cli init` again. ## Messages ### `Rate limit exceeded` - Where: Ingest API response (HTTP 429, header Retry-After: 60) - Message: `Rate limit exceeded` - What it means: The workspace sent more errors in the last minute than its plan’s burst limit. The reply includes `limit`, `remaining` and an `upgrade` hint. A loop that throws on every request is the usual cause. - Fix: - Wait for the `Retry-After` seconds; nothing else is needed. - Fix the error that repeats: LAWDE already groups the repeats into one issue. - If the traffic is real, compare burst limits on [Pricing](https://www.lawde.net/pricing). ### `Rate limit exceeded` - Where: Ingest API response (HTTP 429, "scope": "api_key_hourly" or "api_key_daily") - Message: `Rate limit exceeded` - What it means: This key has its own hourly or daily limit (set on the key, Business and above), and the key reached it. - Fix: - Wait for the `Retry-After` seconds, or raise the limit set on this key. ### `This workspace has reached its errors/day limit for the plan (shared by all members). Quota resets at 00:00 UTC.` - Where: Ingest API response (HTTP 429) - Code: `WORKSPACE_QUOTA_EXCEEDED` - Message: `This workspace has reached its errors/day limit for the plan (shared by all members). Quota resets at 00:00 UTC.` - What it means: The workspace used its whole error quota for the period. Plans with a monthly quota say `errors/month` and “Quota resets on the 1st of each month (UTC).” Errors sent until the reset are not stored. - Fix: - Wait for the reset, or move to a plan with a larger quota: [Pricing](https://www.lawde.net/pricing). - Check [Billing](https://www.lawde.net/billing) for today’s usage, and fix errors that repeat many times. ### `Workspace access is suspended. Update payment to resume ingest.` - Where: Ingest API response (HTTP 402) - Code: `Payment required` - Message: `Workspace access is suspended. Update payment to resume ingest.` - What it means: The workspace’s billing is in a state that pauses ingest. - Fix: - Update payment in [Billing](https://www.lawde.net/billing). Ingest resumes once access is restored. ### `Ingest metering unavailable` - Where: Ingest API response (HTTP 503) - Message: `Ingest metering unavailable` - What it means: LAWDE could not count today’s usage, so it did not store the error rather than risk going over the quota. This is on LAWDE’s side. - Fix: - Retry later. If it continues, check [Status](https://www.lawde.net/status) or email support@lawde.net. --- # Troubleshooting: request and server errors > Exact LAWDE Shield ingest request messages — “Invalid JSON payload”, “Validation failed”, field errors such as “line_number must be a positive integer”, and server errors. Source: https://www.lawde.net/docs/troubleshooting/payloads Each message below is quoted exactly as the ingest API returns it. These mostly come up when you call the [HTTP API](https://www.lawde.net/docs/sdk/http) yourself; the agent builds valid requests. ## Messages ### `Invalid JSON payload` - Where: Ingest API response (HTTP 400) - Message: `Invalid JSON payload` - What it means: The body is not a JSON object: empty, cut short, or not JSON at all. - Fix: - Send `Content-Type: application/json` and a JSON object body. In shell scripts, check the quoting around `-d`. ### `Validation failed` - Where: Ingest API response (HTTP 400, with a details object per field) - Message: `Validation failed` - What it means: The JSON parsed, but a field is missing or has the wrong type. `details` names the field; the field messages are below. - Fix: - Send every required field: `error_class`, `error_message`, `stack_trace`, `file_path` and `line_number`. ### `error_class is required` - Where: Validation failed → details - Message: `error_class is required` - What it means: A required field is missing or empty. The same message is used for `error_message`, `stack_trace` and `file_path`. - Fix: - Send a non-empty string for the field. If you have no stack, send the message as `stack_trace`. ### `line_number must be a positive integer` - Where: Validation failed → details - Message: `line_number must be a positive integer` - What it means: `line_number` is missing, 0, negative or not a whole number. - Fix: - Send the crash line as a whole number from 1 up. ### `app_id must be a valid UUID` - Where: Validation failed → details - Message: `app_id must be a valid UUID` - What it means: `app_id` is set but is not an app ID. App IDs are UUIDs. - Fix: - Copy the app ID from [Apps](https://www.lawde.net/apps), or leave `app_id` out. ### `Failed to persist error log` - Where: Ingest API response (HTTP 500) - Message: `Failed to persist error log` - What it means: LAWDE could not store the event. This is on LAWDE’s side, not in your request. - Fix: - Retry later. If it continues, check [Status](https://www.lawde.net/status) or email support@lawde.net. ### `Internal Sentinel Ingestion Error` - Where: Ingest API response (HTTP 500) - Message: `Internal Sentinel Ingestion Error` - What it means: An unexpected error on LAWDE’s side. - Fix: - Retry later. If it continues, check [Status](https://www.lawde.net/status) or email support@lawde.net. --- # Troubleshooting: npx @lawdeshield/cli init > Every npx @lawdeshield/cli init message — “the code expired (10 minutes). Run npx @lawdeshield/cli init again.”, approval-page errors, framework detection and “✗ LAWDE did not store the test error” — with its meaning and fix. Source: https://www.lawde.net/docs/troubleshooting/cli Each message below is quoted exactly as the CLI or the lawde.net approval page shows it. Browser sign-in failures print after “Browser sign-in did not finish:”. For a dry run that changes nothing, add `--dry-run`. ## Messages ### `Browser sign-in did not finish: the code expired (10 minutes). Run npx @lawdeshield/cli init again.` - Where: npx @lawdeshield/cli init output - Message: `Browser sign-in did not finish: the code expired (10 minutes). Run npx @lawdeshield/cli init again.` - What it means: Nobody approved the code on lawde.net within 10 minutes. Each code works once. - Fix: - Run `npx @lawdeshield/cli init` again and approve the new code. Or paste a key: `npx @lawdeshield/cli init --paste`. ### `Browser sign-in did not finish: the request was denied on lawde.net.` - Where: npx @lawdeshield/cli init output - Message: `Browser sign-in did not finish: the request was denied on lawde.net.` - What it means: Someone clicked Deny on the approval page. No key was created. - Fix: - Run `npx @lawdeshield/cli init` again and approve, if the code matches the one in your terminal. ### `Browser sign-in did not finish: lost contact with .` - Where: npx @lawdeshield/cli init output - Message: `Browser sign-in did not finish: lost contact with .` - What it means: The CLI could not reach LAWDE many times in a row while waiting for approval. - Fix: - Check your connection or proxy, then run `npx @lawdeshield/cli init` again, or use `--paste`. ### `Browser sign-in did not finish: could not reach ().` - Where: npx @lawdeshield/cli init output - Message: `Browser sign-in did not finish: could not reach ().` - What it means: The CLI could not connect to LAWDE to get a sign-in code. - Fix: - Check your connection. Behind a company proxy, paste a key instead: `npx @lawdeshield/cli init --paste`. ### `Too many sign-in codes from this network. Try again in a few minutes.` - Where: Browser sign-in (HTTP 429), printed after “Browser sign-in did not finish:” - Code: `rate_limited` - Message: `Too many sign-in codes from this network. Try again in a few minutes.` - What it means: Your network asked for many sign-in codes in a short time. - Fix: - Wait a few minutes, or paste a key: `npx @lawdeshield/cli init --paste`. ### `Browser sign-in is not available right now. Paste a key instead (--paste).` - Where: Browser sign-in (HTTP 503) - Code: `unavailable` - Message: `Browser sign-in is not available right now. Paste a key instead (--paste).` - What it means: LAWDE could not start browser sign-in. - Fix: - Run `npx @lawdeshield/cli init --paste` and paste a key from [Settings → API keys](https://www.lawde.net/settings/api-keys). ### `Unknown code. Run npx @lawdeshield/cli init again.` - Where: Browser sign-in (HTTP 404) - Message: `Unknown code. Run npx @lawdeshield/cli init again.` - What it means: LAWDE has no record of this sign-in code. - Fix: - Run `npx @lawdeshield/cli init` again. ### `This code was already used.` - Where: Browser sign-in (HTTP 410) - Message: `This code was already used.` - What it means: A key was already issued for this code. Each code works once. - Fix: - Run `npx @lawdeshield/cli init` again for a new code. ### `This code cannot be used. Run npx @lawdeshield/cli init again.` - Where: Browser sign-in (HTTP 409) - Message: `This code cannot be used. Run npx @lawdeshield/cli init again.` - What it means: The code is no longer in a state that can issue a key. - Fix: - Run `npx @lawdeshield/cli init` again. ### `This code was not found, was already used, or expired. Run npx @lawdeshield/cli init again.` - Where: Approval page on lawde.net - Code: `NOT_FOUND` - Message: `This code was not found, was already used, or expired. Run npx @lawdeshield/cli init again.` - What it means: The code in the link is unknown, already used, or older than 10 minutes. - Fix: - Run `npx @lawdeshield/cli init` again and open the new link. ### `Only people who can manage API keys in this workspace can approve.` - Where: Approval page on lawde.net - Code: `FORBIDDEN` - Message: `Only people who can manage API keys in this workspace can approve.` - What it means: Your role in this workspace cannot create keys. - Fix: - Ask the workspace owner to approve, or to give you permission to manage API keys. ### `Pick the app this key is for.` - Where: Approval page on lawde.net - Code: `APP_REQUIRED` - Message: `Pick the app this key is for.` - What it means: Each key from browser sign-in is made for one app. - Fix: - Choose the app, then approve. No apps? Create one on [Apps](https://www.lawde.net/apps) and reload the page. ### `That app is paused by your plan limits. Activate it in Settings first.` - Where: Approval page on lawde.net - Code: `APP_DORMANT` - Message: `That app is paused by your plan limits. Activate it in Settings first.` - What it means: The workspace has more apps than its plan allows, and this app is paused. - Fix: - Activate the app in Settings, or pick another app. ### `Your plan allows active keys. Choose one to replace.` - Where: Approval page on lawde.net - Code: `KEY_LIMIT` - Message: `Your plan allows active keys. Choose one to replace.` - What it means: The workspace already has as many active keys as its plan allows. - Fix: - Pick a key to replace on the approval page, or revoke one in [Settings → API keys](https://www.lawde.net/settings/api-keys). ### `No package.json in . Run this in your app's folder, or pass --cwd.` - Where: npx @lawdeshield/cli init output - Message: `No package.json in . Run this in your app's folder, or pass --cwd.` - What it means: The command ran outside a Node project. - Fix: - `cd` into your app, or pass `--cwd `. ### `Could not tell which framework this is (looked for Next.js, Express, Medusa v2 or a Node entry file). Run it in your app folder or pass --cwd ; for a Node server, pass --entry .` - Where: npx @lawdeshield/cli init output - Message: `Could not tell which framework this is (looked for Next.js, Express, Medusa v2 or a Node entry file). Run it in your app folder or pass --cwd ; for a Node server, pass --entry .` - What it means: The project has a package.json but no Next.js, Express, Medusa v2 or Node entry file the CLI recognises. - Fix: - For a Node server, pass the file that starts it: `npx @lawdeshield/cli init --entry src/server.js`. - Other stacks: use the [manual setup](https://www.lawde.net/docs/getting-started#manual-setup) or the [HTTP API](https://www.lawde.net/docs/sdk/http). ### `Several packages found. Run again with --cwd .` - Where: npx @lawdeshield/cli init output (with --yes) - Message: `Several packages found. Run again with --cwd .` - What it means: In a monorepo with more than one app, `--yes` cannot choose for you. - Fix: - Pass the package folder: `npx @lawdeshield/cli init --yes --cwd apps/web`. ### `Could not find your server entry file. Run again with --entry , or create lawde.js yourself:` - Where: npx @lawdeshield/cli init output (Express / Node) - Message: `Could not find your server entry file. Run again with --entry , or create lawde.js yourself:` - What it means: The CLI could not find the file that starts your server, so it printed the file to create instead of writing it. - Fix: - Run again with `--entry `, or create the printed `lawde.js` and import it first in your entry file. ### `No API key. Pass --key or set LAWDE_API_KEY.` - Where: npx @lawdeshield/cli init output (with --yes) - Message: `No API key. Pass --key or set LAWDE_API_KEY.` - What it means: With `--yes` there is no one to approve in the browser or paste a key, and no key was given. - Fix: - Set `LAWDE_API_KEY` in the environment (safer than `--key`, which stays in shell history), or run without `--yes`. ### `--app must be an app ID (a UUID). Find it on the app page in the dashboard.` - Where: npx @lawdeshield/cli init output - Message: `--app must be an app ID (a UUID). Find it on the app page in the dashboard.` - What it means: `--app` or `LAWDE_APP_ID` is set to something that is not an app ID, such as the app’s name. - Fix: - Copy the app ID from [Apps](https://www.lawde.net/apps), or leave `--app` out and use browser sign-in, which sets it for you. ### ` failed (exit ). Nothing else was changed.` - Where: npx @lawdeshield/cli init output - Message: ` failed (exit ). Nothing else was changed.` - What it means: Your package manager could not install `@lawdeshield/agent`. The CLI stopped before writing any file. - Fix: - Fix the install error printed above it, then run again. Or install by hand and pass `--no-install`. ### `✗ LAWDE did not store the test error: ` - Where: npx @lawdeshield/cli init output (test error) - Message: `✗ LAWDE did not store the test error: ` - What it means: LAWDE did not confirm it stored the test error, so the CLI shows ✗, never ✓. The reason wraps the ingest reply, for example “the API key was rejected (Invalid or revoked API key.).” Look up the message in brackets on the [API key](https://www.lawde.net/docs/troubleshooting/api-keys), [app](https://www.lawde.net/docs/troubleshooting/apps) or [limits](https://www.lawde.net/docs/troubleshooting/limits) page. - Fix: - Fix the cause in brackets, then run `npx @lawdeshield/cli init` again. Files already written are left unchanged. ### `the API key was rejected ().` - Where: npx @lawdeshield/cli init output (test error reason, HTTP 401) - Message: `the API key was rejected ().` - What it means: LAWDE refused the key. The bracket holds the ingest message, such as “Invalid or revoked API key.” - Fix: - See [Invalid or revoked API key](https://www.lawde.net/docs/troubleshooting/api-keys#invalid-or-revoked-api-key). ### `a limit was reached ().` - Where: npx @lawdeshield/cli init output (test error reason, HTTP 429) - Message: `a limit was reached ().` - What it means: A rate limit or the workspace quota stopped the test error. - Fix: - See [Limits and quotas](https://www.lawde.net/docs/troubleshooting/limits). ### `LAWDE answered without confirming the error was stored.` - Where: npx @lawdeshield/cli init output (test error reason) - Message: `LAWDE answered without confirming the error was stored.` - What it means: LAWDE answered with success but without the issue ID that confirms storage, so the CLI does not claim it worked. - Fix: - Run `npx @lawdeshield/cli init` again. If it repeats, check `--url` (or `LAWDE_URL`) points at https://www.lawde.net. ### `✗ No API key, so no test error was sent.` - Where: npx @lawdeshield/cli init output - Message: `✗ No API key, so no test error was sent.` - What it means: The run ended without a key, so nothing could be checked against LAWDE. - Fix: - Run again and approve in the browser, paste a key with `--paste`, or set `LAWDE_API_KEY`. --- # 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. Source: https://www.lawde.net/docs/troubleshooting/agent Each message below is quoted exactly as the agent or the setup code prints it. ## 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](https://www.lawde.net/docs/getting-started#http)), 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](https://www.lawde.net/docs/troubleshooting/api-keys), [app](https://www.lawde.net/docs/troubleshooting/apps) and [limits](https://www.lawde.net/docs/troubleshooting/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(...) - Message: `[LawdeAgent] apiKey is required` - 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) - Message: `[LAWDE] LAWDE_API_KEY missing — live crash capture disabled` - 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) - Message: `[LAWDE] LAWDE_API_KEY missing — crash capture disabled` - 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 - Message: `[LawdeAgent] captureException failed` - 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.