Skip to content

AUDIT-31: Fix null/empty/unreadable values in audit log field display#37

Open
shubhangiisinghh wants to merge 1 commit intoopenmrs:mainfrom
shubhangiisinghh:AUDIT-31
Open

AUDIT-31: Fix null/empty/unreadable values in audit log field display#37
shubhangiisinghh wants to merge 1 commit intoopenmrs:mainfrom
shubhangiisinghh:AUDIT-31

Conversation

@shubhangiisinghh
Copy link
Copy Markdown

@shubhangiisinghh shubhangiisinghh commented Mar 30, 2026

AUDIT-31: Fix null/empty/unreadable values in audit log field display

Problem

The audit log viewer was displaying raw "null" strings and blank values
for changed fields. This happened because:

  1. String.valueOf(null) produces the literal string "null" not a blank
  2. OpenMRS domain object fields (Patient, User, Location etc.) triggered
    Hibernate proxy loading which failed silently, showing nothing
  3. If either old OR current value failed to read, BOTH were overwritten
    with "Unable to read", losing valid data

Description of what I changed

  • Replaced String.valueOf() with a null-safe toSafeString() helper
  • Null field values now show [No value] instead of the literal string "null"
  • OpenMRS domain objects (Patient, User, Location) now show Type(id=X)
    instead of triggering Hibernate proxy errors that caused blank values
  • Old and current value failures are now handled independently so one
    broken field doesn't wipe out the other

Issue I worked on

see https://openmrs.atlassian.net/browse/AUDIT-31

Checklist: I completed these to help reviewers :)

  • Code style followed
  • Tests added (5 new unit tests in UtilClassUnitTest)
  • mvn clean package passed
  • All tests passed
  • Based on latest main branch

@shubhangiisinghh
Copy link
Copy Markdown
Author

@ManojLL @wikumChamith Would be much grateful if you have a look at this when you get a chance !!

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.

1 participant