Skip to content

[ENG-2735] Add "download troubleshooting data" action to privacy request admin UI#7548

Merged
nreyes-dev merged 7 commits intomainfrom
nreyes/eng-2735
Mar 9, 2026
Merged

[ENG-2735] Add "download troubleshooting data" action to privacy request admin UI#7548
nreyes-dev merged 7 commits intomainfrom
nreyes/eng-2735

Conversation

@nreyes-dev
Copy link
Contributor

@nreyes-dev nreyes-dev commented Mar 3, 2026

Ticket ENG-2735

Description Of Changes

Add "download troubleshooting data" action to privacy request admin UI
image

Code Changes

  • Add diagnostics export query: Introduce getPrivacyRequestDiagnostics in fides/clients/admin-ui/src/features/privacy-requests/privacy-requests.slice.ts (GET privacy-request/${privacy_request_id}/diagnostics) and export useLazyGetPrivacyRequestDiagnosticsQuery.
  • Add download hook: Add useDownloadPrivacyRequestDiagnostics in fides/clients/admin-ui/src/features/privacy-requests/hooks/useDownloadPrivacyRequestDiagnostics.ts to:
    • Fetch download_url via useLazyGetPrivacyRequestDiagnosticsQuery
    • Gate visibility by ScopeRegistryEnum.PRIVACY_REQUEST_READ
    • Show toast errors when the URL can’t be resolved
    • Show an info message when diagnostics are stored locally (non-HTTP URL)
    • Open the download URL in a new tab when it’s a remote URL
  • Wire into request details actions: Update fides/clients/admin-ui/src/features/privacy-requests/PrivacyRequestActionsDropdown.tsx to add a “Download troubleshooting data” action (disabled while the request is fetching) with data-testid="download-troubleshooting-data-btn. This dropdown is rendered on the privacy request details page (fides/clients/admin-ui/src/pages/privacy-requests/[id].tsx).

Steps to Confirm

  1. Start the OSS backend + Admin UI, and ensure at least one privacy request exists (e.g. create one via Privacy Center so it appears in Request Manager).
  2. In Admin UI, go to Privacy requests → Request manager and open any request’s Request details page.
  3. Click the Actions dropdown (top right).
  4. Confirm Download troubleshooting data is present.
  5. Click Download troubleshooting data and confirm behavior:
    • Remote storage: a new tab opens / file download starts (uses returned download_url).
    • Local storage: a toast appears saying “Troubleshooting data stored locally cannot be downloaded” and nothing downloads.
  6. Simulate an API failure (temporarily stop the backend or block the endpoint) and confirm an error toast appears (e.g. “Unable to resolve download URL”) and the action becomes clickable again after the request completes.
  7. Verify the action is not shown for a user lacking PRIVACY_REQUEST_READ.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Summary by CodeRabbit

  • New Features
    • Added a "Download troubleshooting data" action to the privacy request Admin UI dropdown so users can retrieve diagnostics exports for a privacy request.
    • The action appears only when allowed, shows loading state, informs users if data is stored locally, and initiates a direct download when a remote URL is available.

@vercel
Copy link
Contributor

vercel bot commented Mar 3, 2026

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

Project Deployment Actions Updated (UTC)
fides-plus-nightly Ready Ready Preview, Comment Mar 9, 2026 5:53pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
fides-privacy-center Ignored Ignored Mar 9, 2026 5:53pm

Request Review

(delete empty trailing line)
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7faaeec-0d6c-465c-9a4a-9702786bb50b

📥 Commits

Reviewing files that changed from the base of the PR and between 13c69ec and dcaae49.

📒 Files selected for processing (1)
  • clients/admin-ui/src/features/privacy-requests/PrivacyRequestActionsDropdown.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • clients/admin-ui/src/features/privacy-requests/PrivacyRequestActionsDropdown.tsx

📝 Walkthrough

Walkthrough

Adds a "Download troubleshooting data" action to the privacy request Admin UI: new API endpoint for diagnostics, a lazy query hook with permission checks and download logic, new response types, and a conditional dropdown menu item that triggers the download flow.

Changes

Cohort / File(s) Summary
Changelog Entry
changelog/ENG-2735-download-troubleshooting-data.yaml
New changelog entry documenting the "Download troubleshooting data" action (PR 7548).
Type Definitions
clients/admin-ui/src/types/api/models/PrivacyRequestDiagnosticsExportResponse.ts, clients/admin-ui/src/types/api/index.ts
Adds PrivacyRequestDiagnosticsExportResponse type (download_url, storage_type, object_key, created_at) and exports it from API index.
API & State Management
clients/admin-ui/src/features/privacy-requests/privacy-requests.slice.ts
Adds getPrivacyRequestDiagnostics GET endpoint (privacy-request/{privacy_request_id}/diagnostics) and exposes useLazyGetPrivacyRequestDiagnosticsQuery.
Hook Implementation
clients/admin-ui/src/features/privacy-requests/hooks/useDownloadPrivacyRequestDiagnostics.ts
New hook exposing showDownloadTroubleshootingData, downloadTroubleshootingData, and isLoading; performs lazy query, enforces read permission, handles errors, distinguishes remote vs local storage, and initiates programmatic download for remote URLs.
UI Integration
clients/admin-ui/src/features/privacy-requests/PrivacyRequestActionsDropdown.tsx
Imports and uses the new hook; conditionally adds "Download troubleshooting data" dropdown item with disabled state during loading.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as PrivacyRequestActionsDropdown
    participant Hook as useDownloadPrivacyRequestDiagnostics
    participant API as privacyRequestApi
    participant Browser as Browser/Download

    User->>UI: Click "Download troubleshooting data"
    UI->>Hook: downloadTroubleshootingData()
    Hook->>API: useLazyGetPrivacyRequestDiagnosticsQuery -> GET /privacy-request/{id}/diagnostics
    API-->>Hook: PrivacyRequestDiagnosticsExportResponse
    Hook->>Hook: extract download_url & check storage_type
    alt Remote URL
        Hook->>Browser: create anchor & trigger download
        Browser-->>User: file downloaded
    else Local storage
        Hook-->>User: show info (data stored locally)
    end
    Hook-->>UI: update isLoading
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • lucanovera

Poem

🐰 Click, and diagnostics take flight,
A tiny file through clouds tonight —
From request to anchor, swift and neat,
Troubleshooting data, ready to greet,
Hooray, the rabbit cheers: download complete! 🥕📥

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a 'download troubleshooting data' action to the privacy request admin UI, with the ticket reference.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all major template sections including description of changes, code changes with file-specific details, detailed steps to confirm the implementation, and a completed pre-merge checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nreyes/eng-2735

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

@nreyes-dev nreyes-dev marked this pull request as ready for review March 4, 2026 19:11
@nreyes-dev nreyes-dev requested a review from a team as a code owner March 4, 2026 19:11
@nreyes-dev nreyes-dev requested review from jpople and removed request for a team March 4, 2026 19:11
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR adds a "Download troubleshooting data" action to the privacy request admin UI. It introduces a new RTK Query endpoint (GET privacy-request/{id}/diagnostics), a custom hook (useDownloadPrivacyRequestDiagnostics) that fetches the download URL and triggers a browser download or shows an appropriate toast, and wires this into the existing PrivacyRequestActionsDropdown.

The overall approach is well-structured and consistent with the existing useDownloadPrivacyRequestResults hook. Two issues require attention:

  1. preferCacheValue: true (line 29 of the hook): Passing true as the second argument instructs RTK Query to serve previously cached responses instead of re-fetching. If the backend returns time-limited presigned URLs (e.g., AWS S3 pre-signed URLs), repeated clicks within the same session will silently reuse the cached — and potentially expired — URL, causing download failures.

  2. Dead code in error handler (lines 32-41): The inner if (result.error) check is always true within the outer if ("error" in result) block due to RTK Query's type guarantees, making the else branch unreachable. This can be simplified by removing the redundant inner check.

Confidence Score: 2/5

  • Not safe to merge — the preferCacheValue: true argument in line 29 causes stale/expired presigned URLs to be served on repeated clicks, which is a real functional bug for time-limited download URLs.
  • The PR implementation is well-structured and consistent with existing patterns, but contains a critical logic issue with preferCacheValue: true that will cause stale URLs to be reused on repeated clicks. This is a real-world problem for backends returning time-limited presigned URLs. Additionally, there's unnecessary dead code in error handling (a minor style issue). Both require fixes before merge.
  • clients/admin-ui/src/features/privacy-requests/hooks/useDownloadPrivacyRequestDiagnostics.ts — specifically lines 27-30 (preferCacheValue argument) and lines 32-41 (dead code branch).

Last reviewed commit: 315a8cb

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@clients/admin-ui/src/features/privacy-requests/hooks/useDownloadPrivacyRequestDiagnostics.ts`:
- Around line 27-30: The code is passing preferCacheValue=true to
fetchDiagnostics which may return stale presigned download_url; update the call
in useDownloadPrivacyRequestDiagnostics (the fetchDiagnostics trigger) to omit
the second boolean argument so it always fetches fresh data: replace
fetchDiagnostics({ privacy_request_id: privacyRequest.id }, true) with a
single-argument call fetchDiagnostics({ privacy_request_id: privacyRequest.id })
(or otherwise remove/disable the preferCacheValue flag) so presigned URLs are
not served from cache.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bea76d71-61be-4a68-a00c-6c87fee13ccf

📥 Commits

Reviewing files that changed from the base of the PR and between 2c0ee18 and 315a8cb.

📒 Files selected for processing (5)
  • changelog/ENG-2735-download-troubleshooting-data.yaml
  • clients/admin-ui/src/features/privacy-requests/PrivacyRequestActionsDropdown.tsx
  • clients/admin-ui/src/features/privacy-requests/hooks/useDownloadPrivacyRequestDiagnostics.ts
  • clients/admin-ui/src/features/privacy-requests/privacy-requests.slice.ts
  • clients/admin-ui/src/features/privacy-requests/types.ts

Copy link
Contributor

@jpople jpople left a comment

Choose a reason for hiding this comment

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

Looks good overall, couple nits about the code.

@nreyes-dev nreyes-dev enabled auto-merge March 9, 2026 17:59
@nreyes-dev nreyes-dev added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 8bfbde3 Mar 9, 2026
47 checks passed
@nreyes-dev nreyes-dev deleted the nreyes/eng-2735 branch March 9, 2026 19:02
mfbrown pushed a commit that referenced this pull request Mar 12, 2026
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.

2 participants