Skip to content

Commit 494e380

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 a3967af commit 494e380

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
@@ -538,8 +538,15 @@ private function getTypedValue(
538538
&& $knownType > 0
539539
&& !$this->isTyped(self::VALUE_MIXED, $knownType)
540540
&& !$this->isTyped($type, $knownType)) {
541-
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
542-
throw new AppConfigTypeConflictException('conflict with value type from database');
541+
$requestedType = $storedType = null;
542+
try {
543+
$requestedType = $this->convertTypeToString($type);
544+
$storedType = $this->convertTypeToString($knownType);
545+
} catch (AppConfigIncorrectTypeException) {
546+
// can be ignored, this was just needed for a better exception message.
547+
}
548+
$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]);
549+
throw new AppConfigTypeConflictException('Config value ' . $app . '/' . $key . ' is stored as ' . ($storedType ?? (string)$knownType) . ' but was requested as ' . ($requestedType ?? (string)$type));
543550
}
544551

545552
/**

0 commit comments

Comments
 (0)