diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php
index a739402d62930190f0a45c5117ee21523e08c7f8..a514eaea482b289b89a615000102d4033a3dce6c 100644
--- a/lib/private/DirectEditing/Manager.php
+++ b/lib/private/DirectEditing/Manager.php
@@ -45,6 +45,8 @@ use OCP\IUserSession;
 use OCP\L10N\IFactory;
 use OCP\Security\ISecureRandom;
 use OCP\Share\IShare;
+use function array_key_exists;
+use function in_array;
 
 class Manager implements IManager {
 
@@ -140,6 +142,9 @@ class Manager implements IManager {
 		if ($editorId === null) {
 			$editorId = $this->findEditorForFile($file);
 		}
+		if (!array_key_exists($editorId, $this->editors)) {
+			throw new \RuntimeException("Editor $editorId is unknown");
+		}
 
 		return $this->createToken($editorId, $file, $filePath);
 	}