{"record":{"id":"3ba79ffaa5757785","repo":"pallets/flask","slug":"failed-to-find-attribute-name-r-in-module-nam","errorCode":null,"errorMessage":"Failed to find attribute {name!r} in {module.__name__!r}.","messagePattern":"Failed to find attribute (.+?) in (.+?)\\.","errorType":"exception","errorClass":"NoAppException","httpStatus":null,"severity":"error","filePath":"src/flask/cli.py","lineNumber":170,"sourceCode":"                kw.arg: ast.literal_eval(kw.value)\n                for kw in expr.keywords\n                if kw.arg is not None\n            }\n        except ValueError:\n            # literal_eval gives cryptic error messages, show a generic\n            # message with the full expression instead.\n            raise NoAppException(\n                f\"Failed to parse arguments as literal values: {app_name!r}.\"\n            ) from None\n    else:\n        raise NoAppException(\n            f\"Failed to parse {app_name!r} as an attribute name or function call.\"\n        )\n\n    try:\n        attr = getattr(module, name)\n    except AttributeError as e:\n        raise NoAppException(\n            f\"Failed to find attribute {name!r} in {module.__name__!r}.\"\n        ) from e\n\n    # If the attribute is a function, call it with any args and kwargs\n    # to get the real application.\n    if inspect.isfunction(attr):\n        try:\n            app = attr(*args, **kwargs)\n        except TypeError as e:\n            if not _called_with_wrong_args(attr):\n                raise\n\n            raise NoAppException(\n                f\"The factory {app_name!r} in module\"\n                f\" {module.__name__!r} could not be called with the\"\n                \" specified arguments.\"\n            ) from e\n    else:","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/pallets/flask/blob/3596b1ab61cea85edb8970e83ff61daa073facf8/src/flask/cli.py#L152-L188","documentation":"Raised by find_app_by_string when the parsed name does not exist on the module (getattr raises AttributeError). The FLASK_APP target resolved to a name the module doesn't define.","triggerScenarios":"export FLASK_APP='module:application' where module only defines app, or any typo'd attribute name.","commonSituations":"Wrong attribute name after the colon; renamed the app variable but didn't update FLASK_APP; module-level circular import hiding the attribute.","solutions":["Use the correct attribute name: export FLASK_APP='module:app'.","Verify the attribute exists with python -c 'import module; print(dir(module))'.","Rename the app variable to match FLASK_APP or vice versa."],"exampleFix":"// before\n# export FLASK_APP='module:application'  # module defines 'app' -> raises\n// after\n# export FLASK_APP='module:app'","handlingStrategy":"validation","validationCode":"if not hasattr(module, name):\n    raise AttributeError(f'Module {module.__name__!r} has no attribute {name!r}')","typeGuard":"def module_has_attr(module, name) -> bool:\n    return hasattr(module, name)","tryCatchPattern":"try:\n    app = find_app_by_string(module, app_name)\nexcept NoAppException:\n    # verify attribute name and retry\n    raise","preventionTips":["Verify the attribute name with python -c 'import module; print(dir(module))'.","Keep FLASK_APP and the app variable name in sync.","Avoid circular imports that hide the attribute."],"tags":["cli","flask-app-env","discovery"],"backgroundTag":null,"analyzedSha":"3596b1ab61cea85edb8970e83ff61daa073facf8","analyzedAt":"2026-08-11T20:11:52.622Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}