{"record":{"id":"2f99ee5f7a2a294a","repo":"FoundationAgents/MetaGPT","slug":"no-requirement-document-found","errorCode":null,"errorMessage":"No requirement document found.","messagePattern":"No requirement document found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"metagpt/actions/write_prd.py","lineNumber":157,"sourceCode":"            self.repo = ProjectRepo(self.context.kwargs.project_path)\n            await self.repo.docs.save(filename=REQUIREMENT_FILENAME, content=with_messages[-1].content)\n            self.input_args = AIMessage.create_instruct_value(\n                kvs={\n                    \"project_path\": self.context.kwargs.project_path,\n                    \"requirements_filename\": str(self.repo.docs.workdir / REQUIREMENT_FILENAME),\n                    \"prd_filenames\": [str(self.repo.docs.prd.workdir / i) for i in self.repo.docs.prd.all_files],\n                },\n                class_name=\"PrepareDocumentsOutput\",\n            )\n        else:\n            self.repo = ProjectRepo(self.input_args.project_path)\n        req = await Document.load(filename=self.input_args.requirements_filename)\n        docs: list[Document] = [\n            await Document.load(filename=i, project_path=self.repo.workdir) for i in self.input_args.prd_filenames\n        ]\n\n        if not req:\n            raise FileNotFoundError(\"No requirement document found.\")\n\n        if await self._is_bugfix(req.content):\n            logger.info(f\"Bugfix detected: {req.content}\")\n            return await self._handle_bugfix(req)\n        # remove bugfix file from last round in case of conflict\n        await self.repo.docs.delete(filename=BUGFIX_FILENAME)\n\n        # if requirement is related to other documents, update them, otherwise create a new one\n        if related_docs := await self.get_related_docs(req, docs):\n            logger.info(f\"Requirement update detected: {req.content}\")\n            await self._handle_requirement_update(req=req, related_docs=related_docs)\n        else:\n            logger.info(f\"New requirement detected: {req.content}\")\n            await self._handle_new_requirement(req)\n\n        kvs = self.input_args.model_dump()\n        kvs[\"changed_prd_filenames\"] = [\n            str(self.repo.docs.prd.workdir / i) for i in list(self.repo.docs.prd.changed_files.keys())","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/actions/write_prd.py#L139-L175","documentation":"WritePrd (the Product Manager action) loads the requirement document from the workspace via Document.load(requirements_filename) (default 'requirement.txt' or the new_doc filename). If the loaded Document is falsy — file missing, empty, or load returned an empty Document — it raises FileNotFoundError('No requirement document found.'). The pipeline refuses to write a PRD without an input requirement.","triggerScenarios":"Running WritePrd (or the full software-company flow / 'meta' command) in a workspace where the requirements file does not exist or is empty; passing input_args.requirements_filename pointing at a non-existent file; using --project_path for a directory whose docs/ lacks the requirement file.","commonSituations":"Running metagpt before creating requirement.txt; typos in the requirements filename in config; workspace path misconfigured so the relative path resolves elsewhere; empty requirement file after a failed write.","solutions":["Create the requirements file in the workspace (default: requirement.txt at workspace root) with your feature request text.","Set the correct requirements_filename in your input args/config to point at the existing file.","If using --project_path, confirm the project directory contains the expected docs structure and requirement file.","Verify the file is non-empty; a 0-byte requirement also fails the truthiness check."],"exampleFix":"# before\n$ metagpt \"write a todo app\"   # workspace has no requirement.txt\n\n# after\necho \"write a todo app\" > /path/to/workspace/requirement.txt\n$ metagpt --project_path /path/to/workspace","handlingStrategy":"validation","validationCode":"req_path = workspace / input_args.requirements_filename\nif not req_path.is_file() or req_path.stat().st_size == 0:\n    raise SystemExit(f'Requirement file missing or empty: {req_path}')\nawait write_prd.run(...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create and verify requirement.txt in the workspace before launching the flow.","Use absolute paths for requirements_filename.","Fail fast on empty requirement files in CI smoke tests."],"tags":["prd","requirements","file-not-found","workflow"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}