Skip to content

[importer] import attachments - #20

Merged
capcom6 merged 1 commit into
masterfrom
importer/import-attachments
May 29, 2026
Merged

[importer] import attachments#20
capcom6 merged 1 commit into
masterfrom
importer/import-attachments

Conversation

@capcom6

@capcom6 capcom6 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Attachments from Bitbucket exports can be imported during migration, uploading files to object storage and creating tracked metadata.
    • Import process validates local files before upload and attempts cleanup if metadata creation fails.
    • Import reports counts for imported vs. skipped attachments and includes attachment totals in logs.
    • Importer supports dry-run mode for attachments and maps exported attachments to corresponding issues/tasks.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed167d76-ea5f-4cbf-999b-8c1e6224c98c

📥 Commits

Reviewing files that changed from the base of the PR and between e27ab2a and 810f8d6.

📒 Files selected for processing (7)
  • internal/attachments/models.go
  • internal/attachments/repository.go
  • internal/attachments/service.go
  • internal/commands/importer/import.go
  • internal/commands/importer/importer.go
  • internal/storage/service.go
  • pkg/bitbucket/issues.go
🚧 Files skipped from review as they are similar to previous changes (6)
  • internal/storage/service.go
  • pkg/bitbucket/issues.go
  • internal/attachments/repository.go
  • internal/attachments/service.go
  • internal/attachments/models.go
  • internal/commands/importer/import.go

📝 Walkthrough

Walkthrough

Adds end-to-end attachment import: typed BitBucket export attachments, attachment model constructor and repository import, MinIO upload API, service orchestration to upload and persist attachments (with cleanup on failure), and importer command wiring with dry-run and file validation.

Changes

Attachment import from BitBucket export

Layer / File(s) Summary
BitBucket export attachment model
pkg/bitbucket/issues.go
New exported Attachment type; Export.Attachments is now []Attachment.
Attachment domain model and repository
internal/attachments/models.go, internal/attachments/repository.go
newAttachmentImport constructs attachmentModel with sanitized filename, StatusUploaded, and UploadedAt; Repository.Import inserts the model via Bun and returns the domain Attachment.
File storage upload
internal/storage/service.go
storage.Service.PutObject uploads a local file to MinIO using FPutObject and the service's object key.
Attachment service import orchestration
internal/attachments/service.go
Service.Import stats local file, generates storage key, uploads file via storage service, creates attachment metadata, and deletes uploaded object on metadata creation failure while logging cleanup warnings.
Import command FX wiring
internal/commands/importer/import.go
Registers miniofx.Module() in the FX app and extends ImportResult with AttachmentsImported and AttachmentsSkipped.
Importer attachment processing
internal/commands/importer/importer.go
Importer gains attachmentsSvc; derives attachmentsDir from export path, validates attachment files with os.Stat, respects dry-run, resolves issue->task mapping, calls attachmentsSvc.Import per attachment, and updates import/skip counters and logs.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Importer CLI
  participant Importer as importer.run
  participant AttachSvc as AttachmentsService
  participant Storage as StorageService (MinIO)
  participant Repo as Attachments Repository
  CLI->>Importer: run import command with export file
  Importer->>AttachSvc: Import(taskID, fileName, localPath, uploadedBy)
  AttachSvc->>Storage: PutObject(storageKey, localPath)
  Storage-->>AttachSvc: success / error
  AttachSvc->>Repo: Import(attachmentModel)
  Repo-->>AttachSvc: domain Attachment / error
  AttachSvc->>Storage: DeleteObject(storageKey) on repo error
  AttachSvc-->>Importer: return Attachment / error
  Importer-->>CLI: log result, update counters
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • bit-issues/backend#8: Earlier attachments persistence/service work related to this PR’s repository and service additions.
  • bit-issues/backend#16: Introduced the importer flow and ImportResult that this PR extends with attachment counters and wiring.

Suggested labels

codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[importer] import attachments' directly reflects the main change: adding attachment import functionality to the importer command.
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.

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


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 and usage tips.

@coderabbitai coderabbitai Bot added the codex label May 29, 2026
@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 backend_Darwin_arm64.tar.gz
🍎 Darwin x86_64 backend_Darwin_x86_64.tar.gz
🐧 Linux arm64 backend_Linux_arm64.tar.gz
🐧 Linux i386 backend_Linux_i386.tar.gz
🐧 Linux x86_64 backend_Linux_x86_64.tar.gz
🪟 Windows arm64 backend_Windows_arm64.zip
🪟 Windows i386 backend_Windows_i386.zip
🪟 Windows x86_64 backend_Windows_x86_64.zip

@capcom6
capcom6 force-pushed the importer/import-attachments branch from 3172411 to e27ab2a Compare May 29, 2026 03:40
@capcom6
capcom6 force-pushed the importer/import-attachments branch from e27ab2a to 810f8d6 Compare May 29, 2026 07:46
@capcom6
capcom6 merged commit f7a2b50 into master May 29, 2026
8 checks passed
@capcom6
capcom6 deleted the importer/import-attachments branch May 29, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant