{"id":"d4297c1add866fb2","repo":"python-poetry/poetry","slug":"invalid-layout","errorCode":null,"errorMessage":"Invalid layout","messagePattern":"Invalid layout","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/layouts/__init__.py","lineNumber":12,"sourceCode":"from __future__ import annotations\n\nfrom poetry.layouts.layout import Layout\nfrom poetry.layouts.src import SrcLayout\n\n\n_LAYOUTS = {\"src\": SrcLayout, \"standard\": Layout}\n\n\ndef layout(name: str) -> type[Layout]:\n    if name not in _LAYOUTS:\n        raise ValueError(\"Invalid layout\")\n\n    return _LAYOUTS[name]\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/layouts/__init__.py#L1-L15","documentation":"Raised by poetry.layouts.layout() at src/poetry/layouts/__init__.py:11-12 when the requested layout name is not a key in _LAYOUTS, which only contains 'src' and 'standard'. ValueError. Used by `poetry new --name=...` and similar scaffolding commands.","triggerScenarios":"Calling layout('masonry') or any name other than 'src'/'standard'. Reached via `poetry new --layout=X myproj` or `poetry new --src` (which selects 'src').","commonSituations":"Typo in the --layout flag, or assuming a custom layout is registered when it is not. Developers extending Poetry sometimes expect plugin layouts to be auto-registered.","solutions":["Use one of the supported names: 'src' or 'standard'.","For a src-style project pass `poetry new --src mypkg`.","If you need a custom layout, register it by extending the _LAYOUTS dict in your own code path before calling layout()."],"exampleFix":"# before\n$ poetry new --layout=masonry mypkg\nValueError: Invalid layout\n\n# after\n$ poetry new --src mypkg   # uses 'src' layout","handlingStrategy":"validation","validationCode":"SUPPORTED_LAYOUTS = {'src', 'standard'}\n\ndef validate_layout(name: str) -> None:\n    if name not in SUPPORTED_LAYOUTS:\n        raise ValueError(f'Invalid layout {name!r}; choose from {sorted(SUPPORTED_LAYOUTS)}.')","typeGuard":"def is_known_layout(name: str) -> bool:\n    return name in {'src', 'standard'}","tryCatchPattern":"try:\n    layout_cls = layout(name)\nexcept ValueError as e:\n    if 'Invalid layout' in str(e):\n        layout_cls = layout('standard')  # safe fallback for scaffolding\n    raise","preventionTips":["Only request 'src' or 'standard' for `poetry new`.","Pin your scaffolding choices in project templates."],"tags":["layout","scaffolding","configuration","validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}