diff --git a/src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java b/src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java index 8fa452d46..85e55d688 100644 --- a/src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java +++ b/src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java @@ -12,6 +12,7 @@ public enum NewGTFSErrorType { LANGUAGE_FORMAT(Priority.LOW, "Language should be specified with a valid BCP47 tag."), INTEGER_FORMAT(Priority.MEDIUM, "Incorrect integer format."), FLOATING_FORMAT(Priority.MEDIUM, "Incorrect floating point number format."), + COLUMN_NAME_INVALID(Priority.HIGH, "Column header is not permitted."), COLUMN_NAME_UNSAFE(Priority.HIGH, "Column header contains characters not safe in SQL, it was renamed."), NUMBER_PARSING(Priority.MEDIUM, "Unable to parse number from value."), NUMBER_NEGATIVE(Priority.MEDIUM, "Number was expected to be non-negative."), diff --git a/src/main/java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java b/src/main/java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java index f8e89baa5..4be20c8ed 100644 --- a/src/main/java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java +++ b/src/main/java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java @@ -320,11 +320,14 @@ private int loadInternal (Table table) throws Exception { int keyFieldIndex = -1; for (int h = 0; h < headerCount; h++) { String header = sanitize(csvReader.getHeader(h)); - if (fieldsSeen.contains(header) || "id".equals(header)) { - // FIXME: add separate error for tables containing ID field. + if (fieldsSeen.contains(header)) { errorStorage.storeError(NewGTFSError.forTable(table, DUPLICATE_HEADER).setBadValue(header)); fields[h] = null; - } else { + } else if ("id".equals(header) || header.isEmpty()) { + // Header field cannot be "id" or missing. + errorStorage.storeError(NewGTFSError.forTable(table, COLUMN_NAME_INVALID).setBadValue(header)); + fields[h] = null; + } else { fields[h] = table.getFieldForName(header); fieldsSeen.add(header); if (keyField.equals(header)) {