{"record":{"id":"4ef5ecc80aa2ae63","repo":"langchain-ai/deepagents","slug":"project-root-must-be-absolute-got-self-project-r","errorCode":null,"errorMessage":"project_root must be absolute, got {self.project_root!r}","messagePattern":"project_root must be absolute, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/project_utils.py","lineNumber":44,"sourceCode":"        user_cwd: Authoritative working directory from the app invocation.\n        project_root: Resolved project root for `user_cwd`, if one exists.\n    \"\"\"\n\n    user_cwd: Path\n    project_root: Path | None = None\n\n    def __post_init__(self) -> None:\n        \"\"\"Validate that path fields are absolute.\n\n        Raises:\n            ValueError: If `user_cwd` or `project_root` is not absolute.\n        \"\"\"\n        if not self.user_cwd.is_absolute():\n            msg = f\"user_cwd must be absolute, got {self.user_cwd!r}\"\n            raise ValueError(msg)\n        if self.project_root is not None and not self.project_root.is_absolute():\n            msg = f\"project_root must be absolute, got {self.project_root!r}\"\n            raise ValueError(msg)\n\n    @classmethod\n    def from_user_cwd(cls, user_cwd: str | Path) -> ProjectContext:\n        \"\"\"Build a project context from an explicit user working directory.\n\n        Args:\n            user_cwd: User invocation directory.\n\n        Returns:\n            Resolved project context.\n        \"\"\"\n        resolved_cwd = Path(user_cwd).expanduser().resolve()\n        return cls(\n            user_cwd=resolved_cwd,\n            project_root=find_project_root(resolved_cwd),\n        )\n\n    def resolve_user_path(self, path: str | Path) -> Path:","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/project_utils.py#L26-L62","documentation":"ValueError raised in ProjectContext.__post_init__ when project_root is provided but is a relative path. Like user_cwd, project_root must be absolute so workspace binding and path comparisons remain unambiguous across processes.","triggerScenarios":"Constructing ProjectContext(user_cwd=..., project_root=Path(\".\")) or any relative path; passing a relative root discovered from config or env vars. Note project_root=None is allowed.","commonSituations":"Reading project_root from a settings file stored as a relative path; passing \".\" or the result of os.getcwd() without resolve() on systems where it returns relative; partially migrated configs.","solutions":["Resolve the root: project_root=Path(raw).resolve() before constructing the context","Omit project_root (None) if there is no project, instead of passing a relative placeholder","Fix the config/source so stored project roots are absolute"],"exampleFix":"// before\nctx = ProjectContext(user_cwd=cwd, project_root=Path(config[\"root\"]))\n\n// after\nctx = ProjectContext(user_cwd=cwd, project_root=Path(config[\"root\"]).resolve())","handlingStrategy":"validation","validationCode":"from pathlib import Path\nroot = Path(config[\"project_root\"]).resolve() if config.get(\"project_root\") else None\nctx = ProjectContext(user_cwd=cwd, project_root=root)","typeGuard":"def is_abs_or_none(p: object) -> TypeGuard[Path | None]:\n    return p is None or (isinstance(p, Path) and p.is_absolute())","tryCatchPattern":"try:\n    ctx = ProjectContext(user_cwd=cwd, project_root=root)\nexcept ValueError as e:\n    raise ConfigError(f\"project_root must be absolute: {e}\") from e","preventionTips":["Store project_root as an absolute path in configs","Resolve values read from env vars or settings files","Use None instead of a relative placeholder when there is no project","Resolve after expanduser() for paths containing ~"],"tags":["path","validation","configuration"],"backgroundTag":"path-must-be-absolute","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}