{"record":{"id":"c1390515d4d8c3c2","repo":"dagger/dagger","slug":"main-object-with-name-self-main-name-not-foun","errorCode":null,"errorMessage":"Main object with name '{self._main_name}' not found or class not decorated with '@dagger.object_type'\nIf you believe the module name '{MODULE_NAME}' is incorrectly being converted into PascalCase, please file a bug report.","messagePattern":"Main object with name '(.+?)' not found or class not decorated with '@dagger\\.object_type'\nIf you believe the module name '(.+?)' is incorrectly being converted into PascalCase, please file a bug report\\.","errorType":"exception","errorClass":"ObjectNotFoundError","httpStatus":null,"severity":"error","filePath":"sdk/python/src/dagger/mod/_module.py","lineNumber":139,"sourceCode":"            output = json.dumps(result)\n        except TypeError as e:\n            raise RegistrationError(str(e), e) from e\n        await anyio.Path(TYPE_DEF_FILE).write_text(output)\n\n    async def _typedefs(self) -> str:  # noqa: C901, PLR0912, PLR0915\n        if not self._main_name:\n            msg = \"Main object name can't be empty\"\n            raise ValueError(msg)\n        try:\n            self.get_object(self._main_name)\n        except ObjectNotFoundError as e:\n            msg = (\n                f\"Main object with name '{self._main_name}' not found or class not \"\n                \"decorated with '@dagger.object_type'\\n\"\n                f\"If you believe the module name '{MODULE_NAME}' is incorrectly \"\n                \"being converted into PascalCase, please file a bug report.\"\n            )\n            raise ObjectNotFoundError(msg, extra=e.extra) from None\n\n        mod = dag.module()\n\n        # Object types\n        for obj_name, obj_type in self._objects.items():\n            if self.is_main(obj_type):\n                # Only the main object's constructor is needed.\n                # It's the entrypoint to the module.\n                obj_type.get_constructor(self._converter)\n\n                # Module description from main object's parent module\n                if desc := get_parent_module_doc(obj_type.cls):\n                    mod = mod.with_description(desc)\n\n            # Object/interface type\n            type_def = dag.type_def()\n            if obj_type.interface:\n                type_def = type_def.with_interface(","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/python/src/dagger/mod/_module.py#L121-L157","documentation":"The module's main object (module name converted to PascalCase) must correspond to a class decorated with @dagger.object_type in the registered objects map. If get_object(main_name) raises ObjectNotFoundError, _typedefs re-raises with guidance: either the class is missing the decorator or the PascalCase conversion of MODULE_NAME doesn't match the class name.","triggerScenarios":"Running a Python Dagger module where no class named PascalCase(module_name) exists, or it exists but lacks @dagger.object_type; renaming the module directory without renaming the main class; main class defined in a file not imported by the entrypoint.","commonSituations":"Renaming a module (e.g. dir 'my-mod' requires class 'MyMod'); a typo'd class name; moving the main object into another module without updating names; forgetting the decorator after refactoring.","solutions":["Ensure a class named exactly PascalCase(your-module-name) exists and is decorated with @dagger.object_type (e.g. module 'my-mod' -> class MyMod).","If the desired class name differs, rename the module directory or the class so they correspond.","Verify the module's __init__.py imports the main class so it's registered.","If PascalCase conversion is wrong (e.g. digits/acronyms), file a bug report with the SDK as the message suggests."],"exampleFix":"// before\n# src/my_mod/__init__.py\nclass MyModule:  # no decorator, wrong name for 'my-mod'\n    pass\n\n// after\nimport dagger\n\n@dagger.object_type\nclass MyMod:\n    ...","handlingStrategy":"validation","validationCode":"import re\n\nmodule_name = \"my-mod\"  # from dagger.json\nexpected = \"\".join(p.capitalize() for p in re.split(r\"[-_]\", module_name))\n# ensure a class with this exact name exists and is decorated:\n# @dagger.object_type\n# class MyMod: ...\nassert any(name == expected for name in globals()), f\"missing main object class {expected}\"","typeGuard":"def has_main_object(module_name: str, objects: dict) -> bool:\n    pascal = \"\".join(p.capitalize() for p in re.split(r\"[-_]\", module_name))\n    return pascal in objects","tryCatchPattern":"try:\n    await module.register()\nexcept ObjectNotFoundError as e:\n    logger.error(\"main object missing: %s\", e)\n    raise SystemExit(1) from e","preventionTips":["Keep the main class name equal to PascalCase of the module directory name.","Always decorate the main class with @dagger.object_type.","Import the main class in the module entrypoint (__init__.py).","After renaming a module, rename the class too."],"tags":["python","dagger","module-registration","naming"],"backgroundTag":"main-object-not-found","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}