{"record":{"id":"9c0020eae7396e94","repo":"remix-run/remix","slug":"expect-received-tothrow-requires-a-function-go","errorCode":null,"errorMessage":"expect(received).toThrow() requires a function (got ${typeof received})","messagePattern":"expect\\(received\\)\\.toThrow\\(\\) requires a function \\(got (.+?)\\)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"packages/assert/src/lib/expect.ts","lineNumber":377,"sourceCode":"        () =>\n          arguments.length < 2\n            ? `${stringify(received)} to have property \"${key}\"`\n            : `${stringify(received)} to have property \"${key}\" with value ${stringify(value)}`,\n        value,\n        'toHaveProperty',\n      )\n    },\n    toMatchObject(expected) {\n      check(\n        matchesPartial(received, expected),\n        () => `${stringify(received)} to recursively match ${stringify(expected)}`,\n        expected,\n        'toMatchObject',\n      )\n    },\n    toThrow(expected) {\n      if (typeof received !== 'function') {\n        throw new AssertionError({\n          message: `expect(received).toThrow() requires a function (got ${typeof received})`,\n          operator: 'toThrow',\n        })\n      }\n      let thrown = false\n      let error: unknown\n      try {\n        ;(received as () => unknown)()\n      } catch (e) {\n        thrown = true\n        error = e\n      }\n      let pass = thrown && checkErrorMatch(error, expected)\n      check(\n        pass,\n        () =>\n          thrown\n            ? `error to be ${describeExpectedError(expected)}, got ${stringify(error)}`","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assert/src/lib/expect.ts#L359-L395","documentation":"A `remix.json` was found and loaded, but it has no `db` key, so `config.db === undefined` and the db command has no adapter/connection/migrations settings to work with. The message includes the resolved config path so you know exactly which file to edit.","triggerScenarios":"Running any `remix db <command>` where `remix.json` parses successfully but contains no `\"db\"` section (or it's null/misspelled/nested at the wrong level).","commonSituations":"Apps scaffolded without database support; hand-edited configs; `db` accidentally nested inside another key or removed during refactors.","solutions":["Add a top-level `db` block: `{ \"db\": { \"adapter\": \"sqlite\", ... } }`","Check JSON nesting — `db` must be a top-level key","Validate remix.json with a JSON linter to catch dropped sections"],"exampleFix":"// before\n{ \"name\": \"my-app\" }\n// after\n{\n  \"name\": \"my-app\",\n  \"db\": {\n    \"adapter\": \"sqlite\",\n    \"filename\": { \"env\": \"DATABASE_FILE\", \"default\": \"data.db\" }\n  }\n}","handlingStrategy":"type-guard","validationCode":"import fs from 'node:fs';\nlet config = JSON.parse(fs.readFileSync('remix.json','utf8'));\nif (!('db' in config) || config.db === undefined) throw new Error('Add a db section to remix.json');","typeGuard":"function hasDbConfig(config: unknown): config is { db: Record<string, unknown> } {\n  return typeof config === 'object' && config !== null && 'db' in config && (config as any).db !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Validate remix.json shape before db commands","Keep db as a top-level key","Lint config files in CI"],"tags":["cli","database","config","schema-validation"],"backgroundTag":"config-section-missing","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}