Skip to content

feat(audit): log the space name when a space is deleted - #4112

Merged
asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:feat/860-audit-space-name-on-delete
Nov 24, 2026
Merged

asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:feat/860-audit-space-name-on-delete

Conversation

@asaah262

Copy link
Copy Markdown
Contributor

Description

When a space is purged, the audit service logs a space_deleted event. Its message only had the space id and the storage id, so the audit log didn't say which space was deleted once the space was gone. The message now includes the space name:

user 'uid-123' deleted the space 'space-123' with name 'Marketing' (storage: 'storage-1')

The name comes from the SpaceName field of the SpaceDeleted event, which reva already fills on a purge for both decomposedfs and posix. The wording follows the existing space_created message (… created a space '…' with name '…' …).

Only the human-readable message changes. The other fields of the audit event (action, space_id, …) stay the same. Disabling a space (space_disabled) is unchanged: that event has no name.

Related Issue

  • None

Motivation and Context

Space ids are opaque. Once a space is purged, administrators reading the audit log can no longer look up which space an id belonged to. With the name in the message, they can tell from the audit log alone.

How Has This Been Tested?

  • Test environment: macOS, Go tests.
  • Go tests in services/audit/pkg/service/service_test.go, TestAuditLogging:
    • the existing "Space deleted" case now sets a space name and expects it in the message;
    • new cases for a unicode name and for an event without a name (with name '', like space_created).
    • All three fail without the change (the message has no name) and pass with it.
  • go test -race ./services/audit/... passes. go vet ./services/audit/... reports nothing. gofmt and git diff --check are clean.
  • Not run locally: golangci-lint and the acceptance tests. No acceptance test checks the audit messages.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 0.00% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ 0.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (0b73e9e) 95037 29280 30.81%
Head commit (9095f76) 95037 (+0) 29280 (+0) 30.81% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4112) 3 0 0.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@asaah262
asaah262 marked this pull request as ready for review November 24, 2026 12:18
@asaah262
asaah262 requested a review from pbleser-oc November 24, 2026 12:18
@asaah262
asaah262 merged commit a2f9b5b into opencloud-eu:main Nov 24, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants