1
0
mirror of https://github.com/google/nomulus synced 2026-04-28 20:07:28 +00:00

Handle bad header names in registrar sheet syncing action (#2404)

The existing behavior was to ignore bad header names, in a way that was
counter-intuitive as a user of the Google Sheet. If a header name was bad (which
could just be someone accidentally changing it not realizing it needs to
correspond exactly to the name of the field on the Java object), then all of the
data in that column was just silently left as-is and never updated. This led to
gradually worsening sync and offset shift errors over time.

Now, it will write out an error message into every single cell in the bad
column, so it's clear that the column name is wrong and does not correspond to any
actual data in the DB.

BUG=http://b/332336068
This commit is contained in:
Ben McIlwain
2024-04-19 13:59:58 -04:00
committed by GitHub
parent fa6898167b
commit 91615aef54
2 changed files with 12 additions and 8 deletions

View File

@@ -114,7 +114,7 @@ class SheetSynchronizerTest {
}
@Test
void testSynchronize_unknownFields_doesntUpdate() throws Exception {
void testSynchronize_unknownFields_writesColumnHeaderErrorIntoCell() throws Exception {
existingSheet.add(createRow("a", "c", "b"));
existingSheet.add(createRow("diffVal1", "sameVal", "diffVal2"));
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2", "d", "val3"));
@@ -125,7 +125,7 @@ class SheetSynchronizerTest {
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
List<List<Object>> expectedVals = newArrayList();
expectedVals.add(createRow("val1", "sameVal", "val2"));
expectedVals.add(createRow("val1", "Invalid Sheet column header name", "val2"));
expectedRequest.setData(
newArrayList(new ValueRange().setRange("Registrars!A2").setValues(expectedVals)));
expectedRequest.setValueInputOption("RAW");
@@ -133,7 +133,7 @@ class SheetSynchronizerTest {
}
@Test
void testSynchronize_notFullRow_getsPadded() throws Exception {
void testSynchronize_notFullRow_isHandledCorrectly() throws Exception {
existingSheet.add(createRow("a", "c", "b"));
existingSheet.add(createRow("diffVal1", "diffVal2"));
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "paddedVal", "d", "val3"));
@@ -144,7 +144,7 @@ class SheetSynchronizerTest {
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
List<List<Object>> expectedVals = newArrayList();
expectedVals.add(createRow("val1", "diffVal2", "paddedVal"));
expectedVals.add(createRow("val1", "Invalid Sheet column header name", "paddedVal"));
expectedRequest.setData(
newArrayList(new ValueRange().setRange("Registrars!A2").setValues(expectedVals)));
expectedRequest.setValueInputOption("RAW");