{"record":{"id":"223c5b3897fe7c86","repo":"peass-ng/PEASS-ng","slug":"item-id-is-not-in-the-list","errorCode":null,"errorMessage":"{item_id} is not in the list","messagePattern":"(.+?) is not in the list","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"linPEAS/builder/src/linpeasModule.py","lineNumber":266,"sourceCode":"\n\nclass LinpeasModuleList(list):\n    def __contains__(self, item):\n        # Check if item is already a LinpeasModule object.\n        if isinstance(item, LinpeasModule):\n            return super().__contains__(item)\n        \n        # Otherwise, treat the item as the id of a LinpeasModule.\n        for module in self:\n            if module.id == item:\n                return True\n        return False\n\n    def index(self, item_id):\n        for index, module in enumerate(self):\n            if module.id == item_id:\n                return index\n        raise ValueError(f\"{item_id} is not in the list\")\n\n    def remove(self, item):\n        # If item is an id, find the corresponding object first.\n        if not isinstance(item, LinpeasModule):\n            index = self.index(item)\n            super().pop(index)\n        else:\n            super().remove(item)\n\n    def insert(self, index, item):\n        # Ensure that item is a LinpeasModule object before inserting.\n        if not isinstance(item, LinpeasModule):\n            raise ValueError(\"Item should be an instance of LinpeasModule\")\n        super().insert(index, item)\n    \n    def copy(self):\n        return LinpeasModuleList(super().copy())\n    ","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/linPEAS/builder/src/linpeasModule.py#L248-L284","documentation":"LinpeasModuleList.index() searches the list for a module whose id matches item_id and raises ValueError when no module has that id. It is used internally by remove(), so removing a module by an unknown id string triggers this error.","triggerScenarios":"Calling LinpeasModuleList.index('some_id') or LinpeasModuleList.remove('some_id') where no LinpeasModule in the list has id == 'some_id'.","commonSituations":"Scripting the build pipeline with a hard-coded module id that was renamed or deleted upstream; passing a full path instead of the module id; case/typo differences in the id.","solutions":["Verify the module id against the ids actually present (e.g. [m.id for m in module_list])","Catch ValueError around remove/index if absence is acceptable","Use the LinpeasModule object directly with remove() instead of the id"],"exampleFix":"# before\nmodules.remove(\"linpeas_sudo\")\n# after\nif \"linpeas_sudo\" in [m.id for m in modules]:\n    modules.remove(\"linpeas_sudo\")","handlingStrategy":"try-catch","validationCode":"ids = {m.id for m in module_list}\nif module_id not in ids:\n    print(f\"{module_id} not present; skipping removal\")","typeGuard":"def is_in_list(module_list, item_id) -> bool:\n    return any(m.id == item_id for m in module_list)","tryCatchPattern":"begin\n  modules.remove(module_id)\nrescue ValueError => e\n  puts \"Module not found: #{e.message}\"\nend\n\n# python\ntry:\n    modules.remove(module_id)\nexcept ValueError as e:\n    print(f\"Module not found: {e}\")","preventionTips":["Print [m.id for m in modules] before removing by id","Reference module ids from constants, not hand-typed strings","Remove by LinpeasModule object when you already hold it"],"tags":["python","list","key-not-found"],"backgroundTag":"item-not-in-list","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}