diff --git a/lib/config.py b/lib/config.py
index dc373b118ff6e2f5fa50807fc926f3587fcce51b..6af89c0e76ba40d879d0c93284c0ac29886d6c35 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -886,7 +886,8 @@ class ConfigWriter:
     for nodegroup in self._config_data.nodegroups.values():
       if nodegroup.name == target:
         return nodegroup.uuid
-    raise errors.OpPrereqError("Node group '%s' not found" % target)
+    raise errors.OpPrereqError("Node group '%s' not found" % target,
+                               errors.ECODE_NOENT)
 
   def _UnlockedGetNodeGroup(self, uuid):
     """Lookup a node group.