{"record":{"id":"5f7ff02be180b599","repo":"vercel/ai","slug":"acp-source-packagejson-must-not-be-empty","errorCode":null,"errorMessage":"ACP source.packageJson must not be empty.","messagePattern":"ACP source\\.packageJson must not be empty\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/implementation.ts","lineNumber":60,"sourceCode":"    credentialEnv: settings.credentialEnv,\n    env: settings.env,\n  };\n}\n\nconst EXACT_SEMVER_REGEXP =\n  /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\nconst PACKAGE_NAME_REGEXP =\n  /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/;\nconst EXECUTABLE_NAME_REGEXP = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nconst ENVIRONMENT_VARIABLE_NAME_REGEXP = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport function validateACPV1Implementation(\n  implementation: ACPImplementation,\n): void {\n  const { source } = implementation;\n  if (source.type === 'npm-locked') {\n    if (source.packageJson.length === 0) {\n      throw new Error('ACP source.packageJson must not be empty.');\n    }\n    if (source.pnpmLockYaml.length === 0) {\n      throw new Error('ACP source.pnpmLockYaml must not be empty.');\n    }\n    if (source.pnpmWorkspaceYaml?.length === 0) {\n      throw new Error('ACP source.pnpmWorkspaceYaml must not be empty.');\n    }\n  } else if (source.type === 'npm-simple') {\n    validateNpmSimpleSource({ source });\n  } else if (source.command.trim().length === 0) {\n    throw new Error('ACP source.command must not be empty.');\n  }\n  if (!EXECUTABLE_NAME_REGEXP.test(implementation.executable)) {\n    throw new Error(\n      `ACP executable must be a bare command name without a path; received ${JSON.stringify(implementation.executable)}.`,\n    );\n  }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/implementation.ts#L42-L78","documentation":"validateACPV1Implementation checks an ACPImplementation of type 'npm-locked' for required source artifacts. It throws when source.packageJson is an empty string, since launching the agent from a locked npm workspace requires package.json contents.","triggerScenarios":"Calling createACPV1 with a 'npm-locked' source whose packageJson field is '' (empty string), typically from an unread/failed file load or a placeholder config.","commonSituations":"Build/packaging step that omitted package.json; reading the file with a helper that returned '' on error; hand-written config with an empty placeholder.","solutions":["Populate source.packageJson with the actual package.json file contents before calling createACPV1.","Fix the file-read step so failures surface instead of silently yielding an empty string.","If no lockfile workspace is needed, use a different source.type (e.g. 'npm-simple') with its required fields."],"exampleFix":"// before\ncreateACPV1({ implementation: { source: { type: 'npm-locked', packageJson: '', pnpmLockYaml: lock } } });\n// after\nconst packageJson = await fs.readFile('package.json', 'utf8');\ncreateACPV1({ implementation: { source: { type: 'npm-locked', packageJson, pnpmLockYaml: lock } } });","handlingStrategy":"validation","validationCode":"if (source.type === 'npm-locked' && source.packageJson.length === 0) {\n  throw new Error('source.packageJson is empty; load package.json contents before createACPV1');\n}","typeGuard":null,"tryCatchPattern":"try {\n  createACPV1({ implementation });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('packageJson must not be empty')) {\n    throw new Error('Implementation packaging failed: package.json was not embedded');\n  }\n  throw error;\n}","preventionTips":["Read package.json with error-throwing file APIs (never default to '').","Assert all npm-locked source fields are non-empty in CI before launching.","Bundle required artifacts (package.json, pnpm-lock.yaml) in your packaging step and verify their sizes."],"tags":["acp","validation","configuration","npm"],"backgroundTag":"missing-config-value","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}