{"record":{"id":"dcb944d61ba3430d","repo":"PrefectHQ/fastmcp","slug":"setting-parent-attr-does-not-exist","errorCode":null,"errorMessage":"Setting {parent_attr} does not exist.","messagePattern":"Setting (.+?) does not exist\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/settings.py","lineNumber":55,"sourceCode":"    model_config = SettingsConfigDict(\n        env_prefix=\"FASTMCP_\",\n        env_file=ENV_FILE,\n        extra=\"ignore\",\n        env_nested_delimiter=\"__\",\n        nested_model_default_partial_update=True,\n        validate_assignment=True,\n    )\n\n    def get_setting(self, attr: str) -> Any:\n        \"\"\"\n        Get a setting. If the setting contains one or more `__`, it will be\n        treated as a nested setting.\n        \"\"\"\n        settings = self\n        while \"__\" in attr:\n            parent_attr, attr = attr.split(\"__\", 1)\n            if not hasattr(settings, parent_attr):\n                raise AttributeError(f\"Setting {parent_attr} does not exist.\")\n            settings = getattr(settings, parent_attr)\n        return getattr(settings, attr)\n\n    def set_setting(self, attr: str, value: Any) -> None:\n        \"\"\"\n        Set a setting. If the setting contains one or more `__`, it will be\n        treated as a nested setting.\n        \"\"\"\n        settings = self\n        while \"__\" in attr:\n            parent_attr, attr = attr.split(\"__\", 1)\n            if not hasattr(settings, parent_attr):\n                raise AttributeError(f\"Setting {parent_attr} does not exist.\")\n            settings = getattr(settings, parent_attr)\n        setattr(settings, attr, value)\n\n    home: Path = Path(user_data_dir(\"fastmcp\", appauthor=False))\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/settings.py#L37-L73","documentation":"Settings.get_setting resolves dotted `__`-joined attribute paths (e.g. `server__host`) by walking parent objects. If an intermediate parent segment doesn't exist as an attribute on the current settings object, an AttributeError is raised naming the missing parent. This guards against typos and renamed nested setting groups.","triggerScenarios":"Calling `get_setting(\"foo__bar\")` where `foo` is not an attribute of the Settings object — e.g. a typo like `temp__dir` instead of `temporary_settings__...`, or referencing a nested group removed/renamed in a newer FastMCP version.","commonSituations":"Environment-driven config strings built by concatenation; referencing settings names from outdated docs after an upgrade renamed a nested group; typos in the `__` path prefix.","solutions":["Check spelling of the parent segment against the current Settings class attributes.","After upgrading FastMCP, update paths whose parent group was renamed or removed (check the changelog / settings docs).","Use `hasattr(settings, parent)` in code that resolves user-supplied paths dynamically before calling get_setting."],"exampleFix":"# before\nvalue = get_setting(\"servr__host\")  # typo\n# after\nvalue = get_setting(\"server__host\")","handlingStrategy":"validation","validationCode":"def get_setting_safe(settings, attr):\n    parts = attr.split(\"__\")\n    obj = settings\n    for p in parts[:-1]:\n        if not hasattr(obj, p):\n            raise AttributeError(f\"Unknown settings path: {attr}\")\n        obj = getattr(obj, p)\n    if not hasattr(obj, parts[-1]):\n        raise AttributeError(f\"Unknown setting: {attr}\")\n    return getattr(obj, parts[-1])","typeGuard":null,"tryCatchPattern":"try:\n    value = settings.get_setting(\"server__host\")\nexcept AttributeError as e:\n    log.error(f\"Bad settings path: {e}\")\n    value = DEFAULTS[\"server__host\"]","preventionTips":["Copy settings paths from docs/settings source rather than from memory.","Pin settings path names in tests after every FastMCP upgrade.","Expose a typed helper instead of passing raw `__` strings around."],"tags":["python","attributeerror","settings","nested-attribute","typo"],"backgroundTag":"attribute-not-found","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}