{"record":{"id":"994ae33a1a2b325b","repo":"1Panel-dev/1Panel","slug":"unexpected-container-path","errorCode":null,"errorMessage":"unexpected-container-path","messagePattern":"unexpected-container-path","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/openresty-modules/diagnose-install.sh","lineNumber":271,"sourceCode":"import re\nimport sys\n\nconfig_root = pathlib.Path(sys.argv[1])\nmodules_root = pathlib.Path(sys.argv[2]).resolve()\ncontainer_prefix = \"/usr/local/openresty/nginx/modules/1panel/\"\npattern = re.compile(r\"^\\s*load_module\\s+([^;]+);\", re.MULTILINE)\nfailed = False\nprint(\"config\\tcontainer_path\\thost_path\\tresult\")\nif config_root.exists():\n    for config in sorted(config_root.glob(\"1panel-module-*.conf\")):\n        content = config.read_text(encoding=\"utf-8\")\n        for value in pattern.findall(content):\n            container_path = value.strip().strip('\"\\'')\n            result = \"OK\"\n            host_path = \"\"\n            try:\n                if not container_path.startswith(container_prefix):\n                    raise ValueError(\"unexpected-container-path\")\n                relative = pathlib.PurePosixPath(container_path[len(container_prefix):])\n                if \"..\" in relative.parts:\n                    raise ValueError(\"unsafe-path\")\n                resolved = (modules_root / pathlib.Path(*relative.parts)).resolve(strict=True)\n                if modules_root not in resolved.parents or not resolved.is_file():\n                    raise ValueError(\"missing-artifact\")\n                host_path = str(resolved)\n            except Exception as error:\n                result = str(error)\n                failed = True\n            print(\"\\t\".join([config.name, container_path, host_path, result]))\nsys.exit(1 if failed else 0)\nPY\n    then\n        mark_passed \"managed load_module configs\"\n    else\n        mark_failed \"managed load_module configs\"\n    fi","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/scripts/openresty-modules/diagnose-install.sh#L253-L289","documentation":"Raised while parsing managed nginx configs (1panel-module-*.conf) when a load_module directive's argument does not start with the expected container prefix path. The diagnostic maps container paths to host paths under the modules root, so an unexpected prefix means it cannot even attempt the mapping.","triggerScenarios":"A 1panel-module-*.conf contains load_module /usr/local/openresty/nginx/modules/x.so (or any path not beginning with container_prefix); running diagnose-install.sh's config check finds it via the regex ^\\s*load_module\\s+([^;]+);.","commonSituations":"Someone hand-edited a managed config and used the openresty default module dir; a module install template rendered the wrong base path; configs written for a different container image layout.","solutions":["Edit the 1panel-module-*.conf so load_module uses the expected container path prefix (the one 1Panel mounts the modules volume at)","Reinstall the module through 1Panel so the managed config is regenerated correctly","Move hand-customized module loads out of the managed 1panel-module-*.conf files into your own include"],"exampleFix":"# before\nload_module /usr/local/openresty/nginx/modules/1panel-foo.so;\n# after\nload_module /usr/local/bin/1panel/modules/1panel-foo.so;  # use the configured container_prefix","handlingStrategy":"validation","validationCode":"grep -rn 'load_module' /opt/1panel/apps/openresty/openresty/conf/conf.d/1panel-module-*.conf | grep -v '<container_prefix>'  # must be empty","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit managed 1panel-module-*.conf files; change modules through 1Panel","Templatize the container prefix from one variable so all generated configs agree"],"tags":["nginx","load-module","openresty","config"],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}