{"record":{"id":"d2976f24a9637388","repo":"prisma/prisma","slug":"file-does-not-contain-a-json-object","errorCode":null,"errorMessage":"${file} does not contain a JSON object","messagePattern":"(.+?) does not contain a JSON object","errorType":"exception","errorClass":"ShellConfigError","httpStatus":null,"severity":"error","filePath":"packages/0-config/tsdown/shell-build.ts","lineNumber":557,"sourceCode":"    dir = parent;\n  }\n}\n\n/**\n * The flat, `__`-separated form of a `/`-separated entry or file name. Build\n * outputs are named after this, and `shellExports` maps it back.\n */\nfunction flatEntryName(name: string): string {\n  return name.replaceAll('/', '__');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction readJson(file: string): Record<string, unknown> {\n  const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));\n  if (!isRecord(parsed)) throw new ShellConfigError(`${file} does not contain a JSON object`);\n  return parsed;\n}\n\nfunction stringField(manifest: Record<string, unknown>, field: string, context: string): string {\n  const value = manifest[field];\n  if (typeof value !== 'string') {\n    throw new ShellConfigError(`package.json of ${context} has no string \"${field}\" field`);\n  }\n  return value;\n}\n\nfunction recordField(manifest: Record<string, unknown>, field: string): Record<string, unknown> {\n  const value = manifest[field] ?? {};\n  if (!isRecord(value)) throw new ShellConfigError(`package.json \"${field}\" is not an object`);\n  return value;\n}\n\nfunction stringRecordField(","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/prisma/prisma/blob/a20d61fb6f095e636e6420ac2871c24f2dece4bb/packages/0-config/tsdown/shell-build.ts#L539-L575","documentation":"Thrown by `readJson` when a package.json parses to something that is not a JSON object (e.g. an array, a bare string/number, or `null`). Every consumer of a manifest expects a record; `isRecord` rejects arrays and primitives so downstream field reads do not crash with a confusing type error.","triggerScenarios":"Any package.json read by the shell build (internal package manifests, the shell's own manifest) whose top-level value is `null`, an array, or a scalar. Reached at shell-build.ts:557 inside `readJson`.","commonSituations":"Corrupted/truncated package.json. A generated package.json that mistakenly emitted a list. Editing accidents that wrapped the object in `[ ... ]`.","solutions":["Open the named file and ensure its top-level value is a JSON object `{ ... }`.","Re-run `pnpm install` / regenerate the file if it was machine-produced.","Validate with `node -e 'JSON.parse(require(\"fs\").readFileSync(\"<file>\",\"utf8\"))'` then fix the structure."],"exampleFix":"// before: <file> contents are [] or null\n// after\n{\n  \"name\": \"@internal/foo\",\n  \"version\": \"0.0.0\"\n}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\n\nfunction readJsonObject(file: string): Record<string, unknown> {\n  const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));\n  if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n    throw new Error(`${file} does not contain a JSON object`);\n  }\n  return parsed as Record<string, unknown>;\n}","typeGuard":"function isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}","tryCatchPattern":null,"preventionTips":["Validate package.json shape before invoking the shell build.","Don't hand-edit manifests with tools that can emit arrays/scalars."],"tags":["shell-build","package-json","configuration","validation"],"backgroundTag":null,"analyzedSha":"a20d61fb6f095e636e6420ac2871c24f2dece4bb","analyzedAt":"2026-08-11T15:42:48.797Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}