Skip to content

Commit 9e2be5d

Browse files
authored
Merge pull request #63450 from nextcloud/fix/config/lexicon-type-mismatch-message
fix(appconfig): make type-conflict error self-explanatory
2 parents 6c5658b + af54c76 commit 9e2be5d

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)