Skip to content

Commit 6e016b9

Browse files
ChristophWurstbackportbot[bot]
authored andcommitted
fix(appconfig): make type-conflict error self-explanatory
When a stored app config value has a different type than the one an app requests via a typed getter, getTypedValue() threw the opaque message 'conflict with value type from database' with no app, key or type information. Admins had no way to tell which key was affected or why. Name the config key and both types (using convertTypeToString(), like the setTypedValue() throw already does) in the log line and exception message. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
1 parent 85490eb commit 6e016b9

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/private/AppConfig.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,15 @@ private function getTypedValue(
526526
&& $knownType > 0
527527
&& !$this->isTyped(self::VALUE_MIXED, $knownType)
528528
&& !$this->isTyped($type, $knownType)) {
529-
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
530-
throw new AppConfigTypeConflictException('conflict with value type from database');
529+
$requestedType = $storedType = null;
530+
try {
531+
$requestedType = $this->convertTypeToString($type);
532+
$storedType = $this->convertTypeToString($knownType);
533+
} catch (AppConfigIncorrectTypeException) {
534+
// can be ignored, this was just needed for a better exception message.
535+
}
536+
$this->logger->warning('Config value {app}/{key} is stored as {storedType} but was requested as {requestedType}', ['app' => $app, 'key' => $key, 'storedType' => $storedType ?? $knownType, 'requestedType' => $requestedType ?? $type]);
537+
throw new AppConfigTypeConflictException('Config value ' . $app . '/' . $key . ' is stored as ' . ($storedType ?? (string)$knownType) . ' but was requested as ' . ($requestedType ?? (string)$type));
531538
}
532539

533540
/**

0 commit comments

Comments
 (0)