Skip to content

feat: add actor_id filter to audit logs#5764

Merged
PrestigePvP merged 6 commits intomainfrom
tre/eng-4412-actorid-lookup
Mar 23, 2026
Merged

feat: add actor_id filter to audit logs#5764
PrestigePvP merged 6 commits intomainfrom
tre/eng-4412-actorid-lookup

Conversation

@PrestigePvP
Copy link
Copy Markdown
Contributor

Context

  • Add actor_id as a filterable item in the Audit log front end
  • Actor was already supported on the backend, just needed to wire up the front end and add suggestions
  • Also includes ID / type mismatch detection (see screenshot 2)

Screenshots

image image

Steps to verify the change

Go into audit log locally

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

@linear
Copy link
Copy Markdown

linear bot commented Mar 19, 2026

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 19, 2026

Greptile Summary

This PR wires up the existing backend actor filter to the frontend audit log search UI, adding an actor_id chip filter with autocomplete suggestions for users and machine identities, plus a mismatch-detection warning when the chosen ID doesn't match the selected actor type. The backend changes extend the ACTOR_TYPE_TO_METADATA_ID_KEY mapping so the correct JSON metadata field is queried for each actor type in both Postgres and ClickHouse DALs.

Key changes:

  • New useAuditLogActorSuggestions hook fetches org users (all) and identities (up to 100) to populate autocomplete suggestions for the actor_id filter chip.
  • AuditSearchFilter gains an actor_id property with dynamic suggestions and a chip-level warning when the selected ID doesn't appear in the current actor type's suggestion list.
  • ACTOR_TYPE_TO_METADATA_ID_KEY constant maps each ActorType to the JSON key used in actorMetadata, replacing the previous hardcoded userId assumption in both DALs.
  • Deprecated project router gains an actorType query parameter to match the org router.

Issues found:

  • Silent filter bypass (both DALs): When actorId is supplied with an actorType not present in ACTOR_TYPE_TO_METADATA_ID_KEY (e.g. PLATFORM, UNKNOWN_USER), the ID constraint is silently dropped and all logs for that actor type are returned, with no error surfaced to the caller.
  • Identity suggestion limit: The hard-coded limit: 100 in useAuditLogActorSuggestions means orgs with more than 100 identities will see truncated suggestions, and the mismatch-detection logic will produce false warnings for valid identities beyond that limit.
  • Eager user fetch: fetchOrgUsers is triggered on every Audit Logs page mount regardless of whether the user interacts with the actor_id filter, which is an unnecessary network request for most page views.

Confidence Score: 3/5

  • Safe to merge with minor behavioural concerns; no security issues, but the silent actorId filter bypass and the 100-identity cap should be addressed before wide adoption.
  • The frontend feature is well-implemented with a nice UX touch (mismatch warnings), and the parameterized backend queries are injection-safe. The score is reduced because of the silent no-op when an unsupported actorType is paired with an actorId (could mislead API consumers), the hard-coded identity limit that causes false mismatch warnings, and the eager user-list fetch on every page load.
  • backend/src/ee/services/audit-log/audit-log-dal.ts and audit-log-clickhouse-dal.ts (silent filter bypass); frontend/src/hooks/api/auditLogs/useAuditLogActorSuggestions.ts (identity limit + eager fetch).

Important Files Changed

Filename Overview
frontend/src/hooks/api/auditLogs/useAuditLogActorSuggestions.ts New hook that fetches user and identity suggestions for the actor_id filter; hard-coded limit of 100 identities can produce incomplete results and false mismatch warnings, and user data is fetched eagerly on page mount.
backend/src/ee/services/audit-log/audit-log-dal.ts Updated actor-ID filtering to use the new ACTOR_TYPE_TO_METADATA_ID_KEY map; actorId filter is silently bypassed (no-op) when actorType has no mapped metadata key (e.g. PLATFORM, UNKNOWN_USER).
backend/src/ee/services/audit-log/audit-log-clickhouse-dal.ts Same actor-ID filtering update as the Postgres DAL; carries the same silent bypass issue for actor types not present in the metadata key map.
backend/src/ee/services/audit-log/audit-log-types.ts Adds ACTOR_TYPE_TO_METADATA_ID_KEY map; PLATFORM and UNKNOWN_USER are intentionally omitted, and ACME_PROFILE and EST_ACCOUNT share the same "profileId" key without explanation.
frontend/src/pages/organization/AuditLogsPage/components/AuditSearchFilter.tsx Adds actor_id filter chip with mismatch detection; logic is sound for USER and IDENTITY types; freetext fallback allows manual ID entry for unsupported types.
frontend/src/pages/organization/AuditLogsPage/components/LogsSection.tsx Small change to pass searchDerived.actor to the LogsTable filter; correctly falls back to logFilter.actor for preset-driven views.
backend/src/ee/routes/v1/deprecated-project-router.ts Adds actorType query parameter to the deprecated project router and passes it through to the audit log service filter correctly.
backend/src/server/routes/v1/organization-router.ts Adds API docs description to the existing actorType query parameter; no functional change.
docs/documentation/platform/audit-logs.mdx Updates the filter capability description to mention filtering by specific user or identity ID; clear and accurate.

Last reviewed commit: "feat: add actor_id f..."

@maidul98
Copy link
Copy Markdown
Collaborator

maidul98 commented Mar 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

sweet feature, love the auto suggest - couple of comments

Copy link
Copy Markdown
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

one more comment

Copy link
Copy Markdown
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

last comment

Copy link
Copy Markdown
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

LTGM!

Copy link
Copy Markdown
Contributor

@scott-ray-wilson scott-ray-wilson left a comment

Choose a reason for hiding this comment

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

LGTM

@PrestigePvP PrestigePvP merged commit fd3e7d9 into main Mar 23, 2026
12 checks passed
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