Audit trail generates unnecessary logs when changing a subset of the values ​​in a metadata field with multiple values

Open
#5,858 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
angular, typescript
Domain
full-stack

Research direction

The bug is that a submission PATCH with op add on /sections/publicationStep/dc.contributor.author resends the full value list, so the back end removes and re-adds every value and writes a REMOVE/ADD audit pair for each. Start by tracing how the Angular submission form builds that PATCH, then the back-end handler that applies it. Before coding, confirm with maintainers whether the fix belongs in the front end (send only replace for changed values) or in the back-end audit logic (skip unchanged values). Done means only changed values produce audit records.

Written by the indexing model from the issue text.

Description

bug component: audit trail improvement needs discussion

Describe the bug

While investigating the issue https://github.com/DSpace/DSpace/issues/12686 on the backend, I discovered that unnecessary logs are being created when a single value (or a subset of values) of a metadata with multiple values is modified.

For example, for an item with N authors (dc.contributor.author), if only one value is modified, there will be 2 * N_ audit records of type MODIFY_METADATA, one with the action ADD and another REMOVE for each value (even though only one was modified).

This happens because the front-end sends a PATCH with the body ["op": "add", "path": "/sections/publicationStep/dc.contributor.author", "value": [...]] where the complete list of values ​​is sent again.
This causes the back-end to remove all metadata values ​​and add them again, instead of just applying the modifications.

I'm not sure, however, whether this should be handled here on the front-end (sending a single 'replace' for the modified values) or perhaps on the back-end itself (checking if there was an actual change in the metadata value before creating the audit log).

To Reproduce

Steps to reproduce the behavior:

  1. Access an item with more than one value for a given metadata field.
  2. Change a single value from that group of metadata fields, or a subset of the values, and save the changes.
  3. Access the audit tab. There will be a pair of logs (ADD and REMOVE) for each value, including the values ​​that remained the same.

Example:

Tested on this item, changing the name of the first author.

Those two opened logs below are the actual change, the other four are pairs of ADD and REMOVE for each one of the other values (not changed).

Image

Expected behavior

Only metadata values ​​that have actually been modified should generate a pair of audit logs (REMOVE + ADD).

Dominant language
TypeScript
Stars
180
Forks
577
Avg merge
1d 23h
Merged PRs (30d)
95

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DSpace/dspace-angular

All issues in DSpace/dspace-angular

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.