Skip to content

Fix AuthorName.setMiddleName to tolerate null middle names - #11

Merged
mrj4001 merged 1 commit into
masterfrom
fix/authorname-null-middlename
Jul 6, 2026
Merged

mrj4001 merged 1 commit into
masterfrom
fix/authorname-null-middlename

Conversation

@paulalbert1

Copy link
Copy Markdown
Contributor

Problem

AuthorName.setMiddleName throws IllegalArgumentException on null. The AWS SDK v1 DynamoDBMapper calls this setter during unconvert, so any Identity whose stored AuthorName has a null middle name fails to deserialize:

DynamoDBMappingException: Identity[identity]; could not unconvert attribute
  caused by: java.lang.IllegalArgumentException: middle name should not be null.
    at reciter.model.identity.AuthorName.setMiddleName
    at ...DynamoDbCrudRepository.findById
    at reciter.service.dynamo.IdentityServiceImpl.findByUid
    at reciter.controller.ExternalArticleController.addExternalArticle

This surfaces as an HTTP 500 from POST /reciter/external-article/by/uid (and GET /reciter/find/identity/by/uid) for every person with a null middle name. In a sampled cohort of 162 people, 123 (76%) hit it — so the external-article manual-add feature is broadly unusable, not an edge case.

Fix

Middle name is optional, unlike first/last name (required identity fields), so a deserialization setter must tolerate null. setMiddleName(null) now sets middleName=null, middleInitial="" and returns; non-null behavior is unchanged. setFirstName/setLastName keep their required-field guards.

Follow-up (not in this PR)

  • Release a new reciter-identity-model artifact (2.0.11 if unreleased, else 2.0.12).
  • Bump ReCiter/pom.xml from 2.0.10 to the released version and redeploy.

mvn compile verified clean.

Middle name is optional (unlike first/last): many identities have no middle name, so the stored DynamoDB attribute is null. The setter threw IllegalArgumentException on null, which broke Identity deserialization via the DynamoDBMapper — findByUid raised DynamoDBMappingException ("could not unconvert attribute"), surfacing as a 500 in ExternalArticleController.addExternalArticle for any such person (~76% of a sampled cohort). Accept null (middleName=null, middleInitial=""); first/last keep their required-field guards.
@mrj4001
mrj4001 merged commit dc53829 into master Jul 6, 2026
2 checks passed
@ved4006
ved4006 deleted the fix/authorname-null-middlename branch July 17, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants