Skip to content

Commit 6c79e0d

Browse files
committed
Handle unexpected/missing keys on submission page.
These can happen when we change the format of a config and go to submissions in an old database.
1 parent 652bb06 commit 6c79e0d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,9 @@ private function maybeGetErrors(string $type, string $expectedConfigString, stri
12581258
$observedConfig = $this->dj->jsonDecode($observedConfigString);
12591259
$errors = [];
12601260
foreach (array_keys($expectedConfig) as $k) {
1261-
if ($expectedConfig[$k] != $observedConfig[$k]) {
1261+
if (!array_key_exists($k, $observedConfig)) {
1262+
$errors[] = '- ' . preg_replace('/_/', ' ', $k) . ': missing';
1263+
} elseif ($expectedConfig[$k] != $observedConfig[$k]) {
12621264
if ($k === 'hash') {
12631265
$errors[] = '- script has changed';
12641266
} elseif ($k === 'entry_point') {
@@ -1270,6 +1272,11 @@ private function maybeGetErrors(string $type, string $expectedConfigString, stri
12701272
}
12711273
}
12721274
}
1275+
foreach (array_keys($observedConfig) as $k) {
1276+
if (!array_key_exists($k, $expectedConfig)) {
1277+
$errors[] = '- ' . preg_replace('/_/', ' ', $k) . ': unexpected';
1278+
}
1279+
}
12731280
if (!empty($errors)) {
12741281
$allErrors[] = $type . ' changes:';
12751282
array_push($allErrors, ...$errors);

0 commit comments

Comments
 (0)