{"record":{"id":"26c795a1691f8b24","repo":"angular/angular-cli","slug":"invalid-target-json-stringify-target","errorCode":null,"errorMessage":"Invalid target: ${JSON.stringify(target)}.","messagePattern":"Invalid target: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/architect/src/architect.ts","lineNumber":271,"sourceCode":"            if (builderInfo === null) {\n              return of(null);\n            }\n\n            return this._createBuilder(builderInfo, target, options);\n          }),\n        );\n      }),\n      first(null, null),\n    ) as Observable<JobHandler<A, I, O> | null>;\n  }\n}\n\nfunction _getTargetOptionsFactory(host: ArchitectHost) {\n  return createJobHandler<Target, json.JsonValue, json.JsonObject>(\n    (target) => {\n      return host.getOptionsForTarget(target).then((options) => {\n        if (options === null) {\n          throw new Error(`Invalid target: ${JSON.stringify(target)}.`);\n        }\n\n        return options;\n      });\n    },\n    {\n      name: '..getTargetOptions',\n    },\n  );\n}\n\nfunction _getProjectMetadataFactory(host: ArchitectHost) {\n  return createJobHandler<Target, json.JsonValue, json.JsonObject>(\n    (target) => {\n      return host.getProjectMetadata(target).then((options) => {\n        if (options === null) {\n          throw new Error(`Invalid target: ${JSON.stringify(target)}.`);\n        }","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/architect/src/architect.ts#L253-L289","documentation":"The ..getTargetOptions job handler asks the ArchitectHost for options of a given Target object. If the host returns null (no such project/target combination exists in the workspace), it throws 'Invalid target: ...' with the JSON of the target.","triggerScenarios":"Calling architect.getTargetOptions(target) (or scheduling it) with a target whose project or target name does not exist in angular.json / the host's project registry.","commonSituations":"Typos in project or target names; targets removed after angular.json refactors; hardcoding targets that only exist in one workspace configuration; calling before workspace loading completes.","solutions":["Verify the project and target names against angular.json (projects.<name>.architect.<target>)","Use targetFromTargetString with the exact 'project:target' specifier from your config","Check the JSON in the error to see which field is wrong","Regenerate/fix angular.json if the target was renamed (e.g. 'build' vs 'browser')"],"exampleFix":"// before\narchitect.getTargetOptions({ project: 'app', target: 'servee' })\n// after\narchitect.getTargetOptions({ project: 'app', target: 'serve' })","handlingStrategy":"validation","validationCode":"const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst opts = ws.projects?.[target.project]?.architect?.[target.target];\nif (!opts) throw new Error(`Unknown target ${target.project}:${target.target}`);","typeGuard":"function targetExists(ws, target) {\n  return !!ws?.projects?.[target?.project]?.architect?.[target?.target];\n}","tryCatchPattern":"try {\n  const options = await architect.getTargetOptions(target);\n} catch (e) {\n  if (e.message.startsWith('Invalid target:')) {\n    console.error(`No such project/target in workspace: ${e.message}`);\n  }\n  throw e;\n}","preventionTips":["Cross-check target names against angular.json before programmatic scheduling","After migrations/refactors, grep for hardcoded project:target strings","Centralize target construction through targetFromTargetString with validated input"],"tags":["angular","architect","target-options","workspace-config"],"backgroundTag":"invalid-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}