Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return empty source object for all entity audit events #1074

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/model/query/audits.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const getByEntityId = (entityId, options) => ({ all }) => {

const details = mergeLeft(audit.details, sourceEvent
.map(event => ({ source: { event, submission } }))
.orElse(undefined));
.orElse({ source: {} })); // Add default empty source to all other entity audit events

return new Audit({ ...audit, details }, { actor: audit.aux.actor });
}));
Expand Down
5 changes: 3 additions & 2 deletions test/integration/api/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ describe('Entities API', () => {
logs[1].action.should.be.eql('entity.update.version');
logs[1].details.entity.uuid.should.be.eql('12345678-1234-4123-8234-123456789abc');
logs[1].actor.displayName.should.be.eql('Bob');
logs[1].details.source.should.be.eql({});

logs[2].should.be.an.Audit();
logs[2].action.should.be.eql('entity.create');
Expand Down Expand Up @@ -942,7 +943,7 @@ describe('Entities API', () => {
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/audits')
.expect(200)
.then(({ body: logs }) => {
logs[0].details.should.not.have.property('source');
logs[0].details.source.should.eql({});
});

await asAlice.patch('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc?force=true')
Expand All @@ -952,7 +953,7 @@ describe('Entities API', () => {
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/audits')
.expect(200)
.then(({ body: logs }) => {
logs[0].details.should.not.have.property('source');
logs[0].details.source.should.eql({});
});
}));

Expand Down
Loading