diff --git a/pipeline/transformer/transformer_marc_common/src/main/scala/weco/pipeline/transformer/marc_common/transformers/subjects/MarcSubject.scala b/pipeline/transformer/transformer_marc_common/src/main/scala/weco/pipeline/transformer/marc_common/transformers/subjects/MarcSubject.scala index 011d2fbafd..5758eafb52 100644 --- a/pipeline/transformer/transformer_marc_common/src/main/scala/weco/pipeline/transformer/marc_common/transformers/subjects/MarcSubject.scala +++ b/pipeline/transformer/transformer_marc_common/src/main/scala/weco/pipeline/transformer/marc_common/transformers/subjects/MarcSubject.scala @@ -28,12 +28,13 @@ trait MarcSubject extends MarcFieldTransformer with MarcHasRecordControlNumber { ): Output = getSubjectConcepts(field) match { case Success(Nil) => None case Success(entities) => - Some( - Subject( - label = getLabel(field).get, - concepts = entities.toList, - id = getIdState(field) - ) + getLabel(field).map( + label => + Subject( + label = label, + concepts = entities.toList, + id = getIdState(field) + ) ) case Failure(exception) => None diff --git a/pipeline/transformer/transformer_marc_common/src/test/scala/weco/pipeline/transformer/marc_common/transformers/MarcSubjectsTest.scala b/pipeline/transformer/transformer_marc_common/src/test/scala/weco/pipeline/transformer/marc_common/transformers/MarcSubjectsTest.scala index d41b685f4a..adfa7d0dd7 100644 --- a/pipeline/transformer/transformer_marc_common/src/test/scala/weco/pipeline/transformer/marc_common/transformers/MarcSubjectsTest.scala +++ b/pipeline/transformer/transformer_marc_common/src/test/scala/weco/pipeline/transformer/marc_common/transformers/MarcSubjectsTest.scala @@ -38,17 +38,28 @@ class MarcSubjectsTest MarcSubjects( MarcTestRecord(fields = Seq( + // with no subfields MarcField( marcTag = "610", subfields = Nil ), + // with blank or blank-like subfields MarcField( - marcTag = "600", + marcTag = "650", + indicator2 = "0", subfields = Seq( MarcSubfield(tag = "a", content = " "), MarcSubfield(tag = "b", content = ""), MarcSubfield(tag = "c", content = " ") ) + ), + // with a dodgy second indicator + MarcField( + marcTag = "650", + indicator2 = "x", + subfields = Seq( + MarcSubfield(tag = "a", content = "Hello, World!") + ) ) ) )