{"record":{"id":"0759a94e54a51255","repo":"pnpm/pnpm","slug":"expected-catalog-field-to-be-an-object-but-found","errorCode":null,"errorMessage":"Expected catalog field to be an object, but found - array","messagePattern":"Expected catalog field to be an object, but found - array","errorType":"exception","errorClass":"InvalidWorkspaceManifestError","httpStatus":null,"severity":"error","filePath":"pnpm11/workspace/workspace-manifest-reader/src/catalogs.ts","lineNumber":17,"sourceCode":"import { InvalidWorkspaceManifestError } from './errors/InvalidWorkspaceManifestError.js'\n\nexport interface WorkspaceNamedCatalogs {\n  [catalogName: string]: WorkspaceCatalog\n}\n\nexport interface WorkspaceCatalog {\n  [dependencyName: string]: string\n}\n\nexport function assertValidWorkspaceManifestCatalog (manifest: { packages?: readonly string[], catalog?: unknown }): asserts manifest is { catalog?: WorkspaceCatalog } {\n  if (manifest.catalog == null) {\n    return\n  }\n\n  if (Array.isArray(manifest.catalog)) {\n    throw new InvalidWorkspaceManifestError('Expected catalog field to be an object, but found - array')\n  }\n\n  if (typeof manifest.catalog !== 'object') {\n    throw new InvalidWorkspaceManifestError(`Expected catalog field to be an object, but found - ${typeof manifest.catalog}`)\n  }\n\n  for (const [alias, specifier] of Object.entries(manifest.catalog)) {\n    if (typeof specifier !== 'string') {\n      throw new InvalidWorkspaceManifestError(`Invalid catalog entry for ${alias}. Expected string, but found: ${typeof specifier}`)\n    }\n  }\n}\n\nexport function assertValidWorkspaceManifestCatalogs (manifest: { packages?: readonly string[], catalogs?: unknown }): asserts manifest is { catalogs?: WorkspaceNamedCatalogs } {\n  if (manifest.catalogs == null) {\n    return\n  }\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/pnpm/pnpm/blob/6261b7f388016d57ca6b90340342411cd1d0d00f/pnpm11/workspace/workspace-manifest-reader/src/catalogs.ts#L1-L35","documentation":"assertValidWorkspaceManifestCatalog (pnpm11/workspace/workspace-manifest-reader/src/catalogs.ts:17) validates the `catalog` field of pnpm-workspace.yaml: it must be an object mapping dependency alias to a version string. An array (the hardcoded first message), any other non-object type, or non-string entry values throw InvalidWorkspaceManifestError, which carries the code INVALID_WORKSPACE_CONFIGURATION (surfacing as ERR_PNPM_INVALID_WORKSPACE_CONFIGURATION).","triggerScenarios":"Writing `catalog:` as a YAML list (e.g. `- lodash: ^4.17.21`) instead of a mapping, or giving a catalog entry a nested map/number instead of a version string, then any pnpm command that loads the workspace manifest.","commonSituations":"First-time catalog authoring in YAML where list-of-pairs syntax feels natural; converting dependency lists into catalogs by copy-paste; YAML gotchas where a value parses as a map (e.g. version strings containing ': ').","solutions":["Rewrite `catalog` as a mapping of alias to version string (see exampleFix).","Quote version strings that contain YAML-special characters.","Re-run `pnpm install` to confirm the manifest now parses and validates."],"exampleFix":"# before (catalog as a list)\ncatalog:\n  - lodash: ^4.17.21\n\n# after (catalog as a map: alias -> version string)\ncatalog:\n  lodash: ^4.17.21","handlingStrategy":"validation","validationCode":"import { assertValidWorkspaceManifestCatalog } from '@pnpm/workspace.manifest-reader'\n\ntry {\n  assertValidWorkspaceManifestCatalog(manifest)\n} catch {\n  // your own, earlier error - before install surfaces ERR_PNPM_INVALID_WORKSPACE_CONFIGURATION\n  throw new Error('pnpm-workspace.yaml: catalog must be a map of alias -> version string')\n}","typeGuard":"function isValidCatalog (value: unknown): value is Record<string, string> {\n  if (value == null) return true\n  if (typeof value !== 'object' || Array.isArray(value)) return false\n  return Object.values(value).every((v) => typeof v === 'string')\n}","tryCatchPattern":null,"preventionTips":["Author catalogs as alias -> version string mappings; never list-of-pairs YAML.","Quote catalog values containing ':' or '#' so YAML keeps them strings.","Run assertValidWorkspaceManifestCatalog in a manifest lint step so mistakes fail at authoring time."],"tags":["workspace","catalog","yaml","validation"],"backgroundTag":"invalid-workspace-config-schema","analyzedSha":"6261b7f388016d57ca6b90340342411cd1d0d00f","analyzedAt":"2026-08-17T18:30:54.750Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}