Skip to content

Commit ae37ad1

Browse files
committed
fix: throw better error message if a user doesn't have a key even though it should have
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent c50f1e3 commit ae37ad1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/private/Config/UserConfig.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,10 @@ private function setTypedValue(
11711171
}
11721172

11731173
$oldValue = null;
1174+
$updateReason = '';
11741175
if ($this->hasKey($userId, $app, $key, $lazy)) {
1176+
$updateReason = 'key exists';
1177+
11751178
/**
11761179
* no update if key is already known with set lazy status and value is
11771180
* not different, unless sensitivity is switched from false to true.
@@ -1206,6 +1209,7 @@ private function setTypedValue(
12061209
// TODO: throw exception or just log and returns false !?
12071210
throw $e;
12081211
}
1212+
$updateReason = 'inserted raised a duplicate contraint';
12091213
}
12101214
}
12111215

@@ -1216,7 +1220,11 @@ private function setTypedValue(
12161220
$currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null;
12171221
if ($currType === null) { // this might happen when switching lazy loading status
12181222
$this->loadConfigAll($userId);
1219-
$currType = $this->valueDetails[$userId][$app][$key]['type'];
1223+
1224+
if (!isset($this->valueDetails[$userId][$app][$key])) {
1225+
throw new UnknownKeyException("unknown key $app $key for $userId even though $updateReason");
1226+
}
1227+
$currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null;
12201228
}
12211229

12221230
/**

0 commit comments

Comments
 (0)