From 41ebeb604769045949e93eb26735534c57dc3dec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jul 2026 16:24:19 +0200 Subject: [PATCH] fix: throw better error message if a user doesn't have a key even though it should have Signed-off-by: Robin Appelman Signed-off-by: Carl Schwan --- lib/private/Config/UserConfig.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index d746a6950865e..473b8f3364d99 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -1141,7 +1141,10 @@ private function setTypedValue( } } + $updateReason = ''; if ($this->hasKey($userId, $app, $key, $lazy)) { + $updateReason = 'key exists'; + /** * no update if key is already known with set lazy status and value is * not different, unless sensitivity is switched from false to true. @@ -1175,6 +1178,7 @@ private function setTypedValue( // TODO: throw exception or just log and returns false !? throw $e; } + $updateReason = 'insert raised a duplicate contraint'; } } @@ -1185,7 +1189,11 @@ private function setTypedValue( $currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null; if ($currType === null) { // this might happen when switching lazy loading status $this->loadConfigAll($userId); - $currType = $this->valueDetails[$userId][$app][$key]['type']; + + if (!isset($this->valueDetails[$userId][$app][$key])) { + throw new UnknownKeyException("unknown key $app $key for $userId even though $updateReason"); + } + $currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null; } /**