Skip to content

Adrian/create owner data export#651

Merged
adrianviquez merged 18 commits intomainfrom
adrian/create-owner-data-export
Jan 20, 2026
Merged

Adrian/create owner data export#651
adrianviquez merged 18 commits intomainfrom
adrian/create-owner-data-export

Conversation

@adrianviquez
Copy link
Contributor

@adrianviquez adrianviquez commented Jan 14, 2026

This is the PR that puts all data export PRs together. Calling all data export fns for sql and archive exports, creating a fn that calls the task via API, addressing size + scale issues. Should be reviewed after #650

https://linear.app/getsentry/issue/CCMRG-2008/create-owner-data-export-file

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Note

Implements end-to-end owner data export via Celery tasks and updates shared config/routing to support them.

  • New worker tasks: ExportOwner, ExportOwnerSQL, ExportOwnerArchives, ExportOwnerFinalize, ExportOwnerCleanup orchestrated with a chord; generates SQL dumps, collects archives, builds tarball + manifest, presigns download URL, and cleans up on failure
  • TaskService.export_owner_data added to trigger export_owner workflow
  • Celery config: defines export task names, routes all app.tasks.export_owner.* to a configurable queue; TaskConfigGroup gains export_owner
  • SQL generator: supports since_date filtering and callable defaults; adds TimescaleDB export wrapper with date support
  • Tests updated to include new task routes and task group mappings

Written by Cursor Bugbot for commit 1c36898. This will update automatically on new commits. Configure here.

@adrianviquez adrianviquez requested a review from a team January 14, 2026 00:54
@sentry
Copy link

sentry bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 2.44755% with 279 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.44%. Comparing base (76b5dfe) to head (1c36898).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/tasks/export_owner_data.py 0.00% 270 Missing ⚠️
...s/shared/shared/owner_data_export/sql_generator.py 0.00% 7 Missing ⚠️
apps/codecov-api/services/task/task.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #651      +/-   ##
==========================================
- Coverage   92.97%   92.44%   -0.54%     
==========================================
  Files        1293     1295       +2     
  Lines       47318    47608     +290     
  Branches     1592     1592              
==========================================
+ Hits        43996    44012      +16     
- Misses       3013     3287     +274     
  Partials      309      309              
Flag Coverage Δ
apiunit 96.54% <33.33%> (-0.02%) ⬇️
sharedintegration 37.55% <46.15%> (-0.01%) ⬇️
sharedunit 85.94% <46.15%> (+<0.01%) ⬆️
workerintegration 58.13% <0.00%> (-1.01%) ⬇️
workerunit 89.72% <0.00%> (-1.55%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

codecov-notifications bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 2.44755% with 279 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/tasks/export_owner_data.py 0.00% 270 Missing ⚠️
...s/shared/shared/owner_data_export/sql_generator.py 0.00% 7 Missing ⚠️
apps/codecov-api/services/task/task.py 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 14, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing adrian/create-owner-data-export (1c36898) with main (6ce1874)

Open in CodSpeed

"export_path": f"exports/{owner_id}/{export_id}/",
"export_date": timezone.now().isoformat(),
"since_date": since_date.isoformat() if since_date else None,
"days_exported": EXPORT_DAYS_DEFAULT,
Copy link

Choose a reason for hiding this comment

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

Manifest days_exported hardcoded, may mismatch actual export

Low Severity

The manifest's days_exported field is hardcoded to EXPORT_DAYS_DEFAULT (60), but the actual since_date used for filtering data may differ. When the export record specifies a custom since_date, the manifest will claim 60 days of data were exported while the actual export may contain more or fewer days. This inconsistency between since_date and days_exported could mislead users about the actual data coverage.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not important, in practice they'll be the same

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

*,
owner_id: int,
export_id: int,
user_id: int | None = None,
Copy link

Choose a reason for hiding this comment

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

Unused user_id parameter never updates export record

Low Severity

The user_id parameter is accepted and documented as "Optional user ID who triggered the export" but is never used. The OwnerExport model has a created_by field (ForeignKey to User) intended to track who triggered the export, but the task never updates this field with the provided user_id. The parameter is passed from TaskService.export_owner_data to ExportOwnerTask.run_impl but then completely ignored, resulting in lost audit trail information about who initiated the export.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

Is user_id for future use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly generic stat stuff; we can change it as we go

try:
export = OwnerExport.objects.get(id=export_id)
except OwnerExport.DoesNotExist:
log.error("OwnerExport %d not found", export_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change export's status to failed here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm in this case the export won't exist, so there's nothing to set its status to 😉

@adrianviquez adrianviquez added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit e423dc8 Jan 20, 2026
51 of 53 checks passed
@adrianviquez adrianviquez deleted the adrian/create-owner-data-export branch January 20, 2026 17:13
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