Skip to content

Import export json#11167

Open
ItzNotABug wants to merge 7 commits into1.8.xfrom
import-export-json
Open

Import export json#11167
ItzNotABug wants to merge 7 commits into1.8.xfrom
import-export-json

Conversation

@ItzNotABug
Copy link
Member

@ItzNotABug ItzNotABug commented Jan 20, 2026

What does this PR do?

Import, Export with JSON.

Test Plan

E2E

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@ItzNotABug ItzNotABug self-assigned this Jan 20, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This PR extends the migrations system to support JSON exports alongside existing CSV functionality. It generalizes CSV-specific infrastructure by: replacing CSV export email translation keys with generic data export keys in the translation file, introducing new API endpoints at /v1/migrations/json/imports and /v1/migrations/json/exports in the migrations controller, refactoring the migrations worker to handle both CSV and JSON exports with a new dataExportType property and renamed methods (handleCSVExportComplete to handleDataExportComplete, sendCSVEmail to sendDataExportEmail), and adding comprehensive end-to-end tests with associated JSON test fixture files to validate the new JSON migration functionality.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Import export json' is directly related to the changeset, which adds JSON import/export functionality to the migrations system alongside existing CSV support.
Description check ✅ Passed The description 'Import, Export with JSON' is related to the changeset, which implements JSON import and export capabilities for data migrations.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@11167

commit: e4558fa

@github-actions
Copy link

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In `@app/config/locale/translations/en.json`:
- Around line 60-74: The failure email signature uses a different placeholder
than the success template; update the emails.dataExport.failure.signature entry
to use the same placeholder as emails.dataExport.success.signature (replace
{{project}} with {{platform}}) so both success
(emails.dataExport.success.signature) and failure
(emails.dataExport.failure.signature) templates render a consistent sign-off.

In `@app/controllers/api/migrations.php`:
- Around line 734-738: The queue setup mistakenly calls setProject twice and
never sets the platform, so update the chain on $queueForMigrations to replace
the duplicate setProject($project) with setPlatform($platform) (keeping the
existing setMigration($migration) and setProject($project) calls) before
->trigger(); so the worker receives the correct $platform value.
🧹 Nitpick comments (1)
src/Appwrite/Platform/Workers/Migrations.php (1)

518-519: Consider adding a null guard for $dataExportType.

While the current call flow guarantees $dataExportType is non-null when this code executes (because handleDataExportComplete is only called for CSV/JSON destinations), adding an explicit guard would make the code more defensive and clearer.

🔧 Optional: Add defensive null check
+        if ($this->dataExportType === null) {
+            throw new \Exception('Data export type not set');
+        }
         $ext = strtolower($this->dataExportType);
         $path = $this->deviceForFiles->getPath($bucketId . '/' . $this->sanitizeFilename($filename) . '.' . $ext);

Comment on lines +60 to +74
"emails.dataExport.success.subject": "Your {{type}} export is ready",
"emails.dataExport.success.preview": "Your data export has been completed successfully.",
"emails.dataExport.success.hello": "Hello {{user}},",
"emails.dataExport.success.body": "Your {{type}} export is ready to download. Click the button below to download your data export.",
"emails.dataExport.success.footer": "This download link will expire in 1 hour.",
"emails.dataExport.success.thanks": "Thanks,",
"emails.dataExport.success.buttonText": "Download {{type}}",
"emails.dataExport.success.signature": "{{platform}} team",
"emails.dataExport.failure.subject": "Your {{type}} export failed - file too large",
"emails.dataExport.failure.preview": "Your data export failed because the file size exceeds your plan limit.",
"emails.dataExport.failure.hello": "Hello {{user}},",
"emails.dataExport.failure.body": "Your {{type}} export could not be completed because the export file size ({{size}}MB) exceeds your plan limit. Please consider upgrading your plan or exporting a smaller dataset.",
"emails.dataExport.failure.footer": "If you have any questions, please contact our support team.",
"emails.dataExport.failure.thanks": "Thanks,",
"emails.dataExport.failure.signature": "{{project}} team",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent placeholder in signature between success and failure templates.

The success template uses {{platform}} for the signature (line 67), while the failure template uses {{project}} (line 74). This will result in different sign-offs:

  • Success: "Appwrite team" (platform name)
  • Failure: "MyProject team" (project name)

This should likely be consistent. Consider using {{platform}} for both to match the success template.

🔧 Suggested fix
-    "emails.dataExport.failure.signature": "{{project}} team",
+    "emails.dataExport.failure.signature": "{{platform}} team",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"emails.dataExport.success.subject": "Your {{type}} export is ready",
"emails.dataExport.success.preview": "Your data export has been completed successfully.",
"emails.dataExport.success.hello": "Hello {{user}},",
"emails.dataExport.success.body": "Your {{type}} export is ready to download. Click the button below to download your data export.",
"emails.dataExport.success.footer": "This download link will expire in 1 hour.",
"emails.dataExport.success.thanks": "Thanks,",
"emails.dataExport.success.buttonText": "Download {{type}}",
"emails.dataExport.success.signature": "{{platform}} team",
"emails.dataExport.failure.subject": "Your {{type}} export failed - file too large",
"emails.dataExport.failure.preview": "Your data export failed because the file size exceeds your plan limit.",
"emails.dataExport.failure.hello": "Hello {{user}},",
"emails.dataExport.failure.body": "Your {{type}} export could not be completed because the export file size ({{size}}MB) exceeds your plan limit. Please consider upgrading your plan or exporting a smaller dataset.",
"emails.dataExport.failure.footer": "If you have any questions, please contact our support team.",
"emails.dataExport.failure.thanks": "Thanks,",
"emails.dataExport.failure.signature": "{{project}} team",
"emails.dataExport.success.subject": "Your {{type}} export is ready",
"emails.dataExport.success.preview": "Your data export has been completed successfully.",
"emails.dataExport.success.hello": "Hello {{user}},",
"emails.dataExport.success.body": "Your {{type}} export is ready to download. Click the button below to download your data export.",
"emails.dataExport.success.footer": "This download link will expire in 1 hour.",
"emails.dataExport.success.thanks": "Thanks,",
"emails.dataExport.success.buttonText": "Download {{type}}",
"emails.dataExport.success.signature": "{{platform}} team",
"emails.dataExport.failure.subject": "Your {{type}} export failed - file too large",
"emails.dataExport.failure.preview": "Your data export failed because the file size exceeds your plan limit.",
"emails.dataExport.failure.hello": "Hello {{user}},",
"emails.dataExport.failure.body": "Your {{type}} export could not be completed because the export file size ({{size}}MB) exceeds your plan limit. Please consider upgrading your plan or exporting a smaller dataset.",
"emails.dataExport.failure.footer": "If you have any questions, please contact our support team.",
"emails.dataExport.failure.thanks": "Thanks,",
"emails.dataExport.failure.signature": "{{platform}} team",
🤖 Prompt for AI Agents
In `@app/config/locale/translations/en.json` around lines 60 - 74, The failure
email signature uses a different placeholder than the success template; update
the emails.dataExport.failure.signature entry to use the same placeholder as
emails.dataExport.success.signature (replace {{project}} with {{platform}}) so
both success (emails.dataExport.success.signature) and failure
(emails.dataExport.failure.signature) templates render a consistent sign-off.

Comment on lines +734 to +738
$queueForMigrations
->setMigration($migration)
->setProject($project)
->setProject($project)
->trigger();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix queue setup: platform is never set.
The second setProject($project) looks like a copy/paste mistake. This leaves $platform unset for the worker and can break the migration flow.

🐛 Suggested fix
 $queueForMigrations
     ->setMigration($migration)
     ->setProject($project)
-    ->setProject($project)
+    ->setPlatform($platform)
     ->trigger();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$queueForMigrations
->setMigration($migration)
->setProject($project)
->setProject($project)
->trigger();
$queueForMigrations
->setMigration($migration)
->setProject($project)
->setPlatform($platform)
->trigger();
🤖 Prompt for AI Agents
In `@app/controllers/api/migrations.php` around lines 734 - 738, The queue setup
mistakenly calls setProject twice and never sets the platform, so update the
chain on $queueForMigrations to replace the duplicate setProject($project) with
setPlatform($platform) (keeping the existing setMigration($migration) and
setProject($project) calls) before ->trigger(); so the worker receives the
correct $platform value.

@github-actions
Copy link

✨ Benchmark results

  • Requests per second: 2,763
  • Requests with 200 status code: 497,315
  • P99 latency: 0.064985803

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 2,763 1,365
200 497,315 245,793
P99 0.064985803 0.152749251

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.

1 participant