Skip to content

fix(audit-logs): use project id for audit log retention update#5882

Merged
akhilmhdh merged 1 commit intoInfisical:mainfrom
syedmazharaliraza:fix/audit-retention-project-id
Apr 6, 2026
Merged

fix(audit-logs): use project id for audit log retention update#5882
akhilmhdh merged 1 commit intoInfisical:mainfrom
syedmazharaliraza:fix/audit-retention-project-id

Conversation

@syedmazharaliraza
Copy link
Copy Markdown
Contributor

@syedmazharaliraza syedmazharaliraza commented Mar 31, 2026

Fixes #5883

Context

This PR fixes a bug in Project Settings → Audit Logs Retention where the frontend sent the project slug in the retention update API path, while the backend endpoint expects a project ID.

Before:

  • Request was sent to:
    PUT /api/v1/projects/<project-slug>/audit-logs-retention
  • Backend treated path param as project ID and returned:
    404 Project with ID '<slug>' not found

After:

  • Request is sent to:
    PUT /api/v1/projects/<project-id>/audit-logs-retention
  • Retention updates succeed as expected.

Screen recording

Before After
Screen.Recording.2026-03-31.at.11.23.33.PM.mov
Screen.Recording.2026-03-31.at.11.26.16.PM.mov

Steps to verify the change

  1. Open a project: Settings → General → Audit Logs Retention.
  2. Change the retention value and click Save.
  3. In Network tab, confirm request URL is:
    • PUT /api/v1/projects/<project-id>/audit-logs-retention
  4. Confirm response is 200 and success toast appears.
  5. Refresh page and verify updated retention value persists.

Type

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

Checklist

@maidul98
Copy link
Copy Markdown
Collaborator

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 31, 2026

Greptile Summary

This PR fixes a bug where the Audit Logs Retention settings page was calling PUT /api/v1/projects/<project-slug>/audit-logs-retention instead of the correct PUT /api/v1/projects/<project-id>/audit-logs-retention, causing a 404 from the backend. The fix is applied consistently across all three frontend layers (DTO type, mutation hook, and component call site).

Changes:

  • types.ts: UpdateAuditLogsRetentionDTO.projectSlugprojectId
  • queries.tsx: URL path parameter updated from projectSlug to projectId
  • AuditLogsRetentionSection.tsx: Call site updated to pass currentProject.id instead of currentProject.slug

The backend route (backend/src/server/routes/v1/project-router.ts, line 507) confirms the /:projectId/audit-logs-retention endpoint uses ProjectFilterType.ID, validating that this fix is correct. A legacy slug-based route still exists in deprecated-project-router.ts but is not used by this fix.

Confidence Score: 5/5

Safe to merge — targeted, correct fix for a 404 bug with no logic regressions.

The change is minimal and precisely addresses the described bug. The backend route was verified to require a project ID (ProjectFilterType.ID), and the fix is applied uniformly across the DTO type, mutation hook, and component. No new logic, no security concerns, no breaking API changes.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/hooks/api/projects/types.ts Updated UpdateAuditLogsRetentionDTO to use projectId: string instead of projectSlug: string, aligning the DTO with the backend's /:projectId/audit-logs-retention route signature.
frontend/src/hooks/api/projects/queries.tsx Mutation function now destructures projectId and interpolates it into the URL, matching the backend's PUT /:projectId/audit-logs-retention endpoint which validates via ProjectFilterType.ID.
frontend/src/pages/project/SettingsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx Call site updated to pass currentProject.id instead of currentProject.slug, completing the fix across all three layers of the frontend.

Reviews (1): Last reviewed commit: "fix: use project id for audit log retent..." | Re-trigger Greptile

@akhilmhdh
Copy link
Copy Markdown
Member

Good find. Thank you for your contribution

@akhilmhdh akhilmhdh merged commit cc0a8c4 into Infisical:main Apr 6, 2026
4 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.

Audit Logs Retention Save Fails with 404 on Project Settings

3 participants