Skip to content

fix(membership): log audit record failures instead of dropping them#1770

Open
AmanGIT07 wants to merge 2 commits into
mainfrom
fix/audit-record-errors
Open

fix(membership): log audit record failures instead of dropping them#1770
AmanGIT07 wants to merge 2 commits into
mainfrom
fix/audit-record-errors

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Summary

Audit record writes in the membership audit helpers discarded their error. They now go through a helper that logs the failure. The member operation still succeeds.

Changes

  • core/membership: route the seven audit record writes through a new createAuditRecord helper
  • On failure the log line carries every field of the record (event, org, resource, target, metadata, timestamp) so the record can be recreated manually
  • Add a test case asserting a failed audit record write does not fail AddOrganizationMember

Technical Details

No caller-visible behavior change: the audit helpers stay fire-and-forget.

Test Plan

  • go test ./core/membership/ passes
  • Build and type checking passes

Audit record writes in the membership audit helpers discarded their
error. Route them through a helper that logs the full record when the
write fails. The member operation still succeeds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 20, 2026 5:15am

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c2ef5478-a854-4a61-9abf-5044b61ccfe6

📥 Commits

Reviewing files that changed from the base of the PR and between 83d6794 and 85eaf9a.

📒 Files selected for processing (1)
  • core/membership/service.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/membership/service.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Membership actions now continue successfully even when audit record storage is temporarily unavailable.
    • When audit record writes fail, the system emits warning details to help with manual recovery, including event and relevant identifiers/names (and actor/target info when available).
    • Existing membership audit logging behavior remains unchanged.
  • Tests

    • Added test coverage to verify membership additions still succeed when audit persistence fails.

Walkthrough

Membership audit persistence is centralized in a helper that logs repository failures with record and actor details. Organization, project, and group membership audit paths use the helper, and member creation tests verify audit failures remain non-fatal.

Changes

Membership audit resilience

Layer / File(s) Summary
Centralize audit record persistence
core/membership/service.go
Adds Service.createAuditRecord, which logs audit record fields, optional target fields, and actor context when repository creation fails.
Route membership audits through the helper
core/membership/service.go, core/membership/service_test.go
Updates organization, project, and group membership audit paths to use the helper and tests successful member addition despite an audit write failure.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: rohilsurana

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d26df683-675f-40e6-b51d-a492932219c0

📥 Commits

Reviewing files that changed from the base of the PR and between cfe2cf3 and 83d6794.

📒 Files selected for processing (2)
  • core/membership/service.go
  • core/membership/service_test.go

Comment thread core/membership/service.go
Comment thread core/membership/service.go
@AmanGIT07
AmanGIT07 requested a review from rohilsurana July 17, 2026 10:17
@coveralls

coveralls commented Jul 17, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29718688336

Coverage increased (+0.02%) to 46.133%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 6 uncovered changes across 1 file (28 of 34 lines covered, 82.35%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
core/membership/service.go 34 28 82.35%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 38348
Covered Lines: 17691
Line Coverage: 46.13%
Coverage Strength: 13.32 hits per line

💛 - Coveralls

The repository enriches the actor from the request context after the
service hands the record over, so the fallback log carried no actor.
Read the same context value and log the actor id and type.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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