Skip to content

Proposal: Address potential null return in getRevisionById for general entities#34

Closed
yousung1020 wants to merge 1 commit intoopenmrs:mainfrom
yousung1020:fix/parse-string-id-to-integer
Closed

Proposal: Address potential null return in getRevisionById for general entities#34
yousung1020 wants to merge 1 commit intoopenmrs:mainfrom
yousung1020:fix/parse-string-id-to-integer

Conversation

@yousung1020
Copy link
Copy Markdown

Description of what I changed

While working on unit tests for AUDIT-14, I noticed a behavior in AuditServiceImpl.getRevisionById() that I would like to discuss.

It appears that UtilClass.getEntityIdAsString() converts all entity IDs to String. However, getRevisionById() currently only processes String IDs for Role and GlobalProperty classes, returning null for other general entities (like Patient or Encounter).
In my local testing, this caused the audit log details (Diffs) to be empty(null) for these general entities because the "Old Value" could not be retrieved from the database.

Issue I worked on

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

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@ManojLL
Copy link
Copy Markdown
Contributor

ManojLL commented Mar 30, 2026

Thanks for the PR, have you got chance to read this : https://openmrs.atlassian.net/wiki/spaces/docs/pages/25477199/Pull+Request+Tips

@yousung1020
Copy link
Copy Markdown
Author

yousung1020 commented Mar 30, 2026

Thank you for sharing the Pull Request Tips, and I apologize for missing the guidelines initially.
Currently, I am unable to create a Jira ticket because my OpenMRS account is still waiting for approval from the infrastructure helpdesk. Once my account is fully set up, I will immediately create a Jira issue and link it to this PR.
Please let me know if there is anything else I should adjust in the meantime. Should I leave this PR open while waiting for the account approval, or do you prefer that I close it and reopen it later? Please let me know how you would like me to proceed.

@Binayak490-cyber
Copy link
Copy Markdown

Hi @yousung1020, I think for now you just close the PR, when you get the permission then you can again open the PR.

@yousung1020
Copy link
Copy Markdown
Author

Thank you for advice!

@yousung1020 yousung1020 closed this Apr 5, 2026
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.

3 participants