diff --git a/src/lib-sieve/sieve-commands.c b/src/lib-sieve/sieve-commands.c
index 67913f617c61c3f8df0e82ede18372d4289ae7ce..6c3f8586227b27f3f150c48f7871c55fa30a54ce 100644
--- a/src/lib-sieve/sieve-commands.c
+++ b/src/lib-sieve/sieve-commands.c
@@ -296,6 +296,24 @@ const char *sieve_command_def_type_name
 	case SCT_NONE: return "command of unspecified type (bug)";
 	case SCT_TEST: return "test";
 	case SCT_COMMAND: return "command";
+	case SCT_HYBRID: return "command or test";
+	default:
+		break;
+	}
+	return "??COMMAND-TYPE??";
+}
+
+const char *sieve_command_type_name
+	(const struct sieve_command *cmd)
+{
+	switch ( cmd->def->type ) {
+	case SCT_NONE: return "command of unspecified type (bug)";
+	case SCT_TEST: return "test";
+	case SCT_COMMAND: return "command";
+	case SCT_HYBRID:
+		if ( cmd->ast_node->type == SAT_TEST )
+			return "test";
+		return "command";
 	default:
 		break;
 	}
diff --git a/src/lib-sieve/sieve-commands.h b/src/lib-sieve/sieve-commands.h
index 8638e1c4ce069fc7de4f8032e84081db93f1144b..d175ba0e307f530df4a743731283449ec06c1f8c 100644
--- a/src/lib-sieve/sieve-commands.h
+++ b/src/lib-sieve/sieve-commands.h
@@ -164,8 +164,6 @@ struct sieve_command {
 	( (cmd)->def == &(definition) )
 #define sieve_command_identifier(cmd) \
 	( (cmd)->def->identifier )
-#define sieve_command_type_name(cmd) \
-	( sieve_command_def_type_name((cmd)->def) )
 
 #define sieve_commands_equal(cmd1, cmd2) \
 	( (cmd1) != NULL && (cmd2) != NULL && (cmd1)->def == (cmd2)->def )
@@ -179,6 +177,8 @@ struct sieve_command *sieve_command_create
 
 const char *sieve_command_def_type_name
 	(const struct sieve_command_def *cmd_def);
+const char *sieve_command_type_name
+	(const struct sieve_command *cmd);
 
 struct sieve_command *sieve_command_prev
 	(struct sieve_command *cmd);