8000 Add readable error for csv imports by ItzNotABug · Pull Request #9947 · appwrite/appwrite · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ItzNotABug
Copy link
Member
@ItzNotABug ItzNotABug commented Jun 1, 2025

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

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 Jun 1, 2025
@coderabbitai
Copy link
Contributor
coderabbitai bot commented Jun 1, 2025

Warning

Rate limit exceeded

@ItzNotABug has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 227c4fd and 149ad1a.

📒 Files selected for processing (1)
  • src/Appwrite/Utopia/Response/Model/Migration.php (2 hunks)
📝 Walkthrough

"""

Walkthrough

A blank line was added for formatting in the projects configuration file. The migration worker's error handling was refactored: error messages are now stored and transmitted as JSON objects, with stack traces and sensitive fields removed before sending in realtime events. The migration document update method was adjusted to exclude certain attributes from the realtime payload and avoid redundant updates. A new filter method was added to the Migration model to sanitize error trace information in migration documents.

Changes

File(s) Change Summary
app/config/collections/projects.php Added a blank line before the 'deployments' collection definition.
src/Appwrite/Platform/Workers/Migrations.php Refactored error handling: errors are now JSON-encoded, stack traces and sensitive fields are sanitized, and realtime payloads exclude sensitive attributes. Removed redundant update calls.
src/Appwrite/Utopia/Response/Model/Migration.php Added filter method to sanitize error trace and resource information from migration documents.

Poem

A hop and a skip, a blank line appears,
While migrations now whisper, not shout out their fears.
Errors are tidy, their traces erased,
JSON in hand, through the system they’re chased.
A rabbit approves, with a twitch of its nose—
Clean code and clear logs, that’s how it goes!
"""

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
github-actions bot commented Jun 1, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
libxml2 2.12.7-r0 CVE-2025-32414 HIGH
libxml2 2.12.7-r0 CVE-2025-32415 HIGH
pyc 3.12.9-r0 CVE-2024-12718 HIGH
pyc 3.12.9-r0 CVE-2025-4138 HIGH
pyc 3.12.9-r0 CVE-2025-4517 HIGH
python3 3.12.9-r0 CVE-2024-12718 HIGH
python3 3.12.9-r0 CVE-2025-4138 HIGH
python3 3.12.9-r0 CVE-2025-4517 HIGH
python3-pyc 3.12.9-r0 CVE-2024-12718 HIGH
python3-pyc 3.12.9-r0 CVE-2025-4138 HIGH
python3-pyc 3.12.9-r0 CVE-2025-4517 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2024-12718 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2025-4138 HIGH
python3-pycache-pyc0 3.12.9-r0 CVE-2025-4517 HIGH
sqlite-libs 3.45.3-r1 CVE-2025-29087 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 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: 1

🧹 Nitpick comments (1)
src/Appwrite/Migration/Version/V23.php (1)

62-62: Fix typo in comment.

There's a typo in the comment: direct access.\ should not have the backslash.

-         * direct access.\
+         * direct access.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dc179b and 6619472.

📒 Files selected for processing (5)
  • app/config/collections/projects.php (2 hunks)
  • src/Appwrite/Migration/Migration.php (1 hunks)
  • src/Appwrite/Migration/Version/V23.php (1 hunks)
  • src/Appwrite/Platform/Workers/Migrations.php (2 hunks)
  • src/Appwrite/Utopia/Response/Model/Migration.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (6)
app/config/collections/projects.php (1)

2345-2361: Excellent schema design for the new error attribute!

The addition of the error attribute to the migrations collection is well-designed:

  • Clear documentation: The multi-line comment effectively explains the purpose and distinguishes it from the existing errors field
  • Appropriate constraints: 256 character limit is reasonable for concise, human-readable error messages
  • Backward compatibility: Non-required and nullable ensures existing migrations won't break
  • Targeted use case: Specifically designed for CSV import failures to be displayed on the frontend

The schema follows established patterns and maintains consistency with other attributes in the collection.

src/Appwrite/Migration/Migration.php (1)

92-92: Standard version mapping addition looks correct.

The new version mapping for '1.8.0' => 'V23' follows the established pattern and maintains chronological order in the versions array.

src/Appwrite/Utopia/Response/Model/Migration.php (1)

88-94: Well-designed API model addition for the error field.

The new error rule is properly structured:

  • Singular vs. plural distinction: Correctly defined as a single string (array => false) to complement the existing errors array field
  • Targeted description: Specifically mentions "CSV migration process" which aligns with the PR objectives
  • Proper defaults: Uses null default to match the database schema's nullable constraint
  • Consistent with schema: Matches the non-required, nullable design from the collections configuration

This provides a clean API interface for accessing concise error messages from CSV migrations.

src/Appwrite/Platform/Workers/Migrations.php (2)

368-368: LGTM: Good placement for error message extraction.

The call to setMigrationError in the finally block ensures that human-readable error messages are captured regardless of how the migration completes, which is the correct approach.


412-434: Well-implemented error message extraction for CSV migrations.

The method correctly:

  • Validates that migration, source, and destination objects exist
  • Restricts functionality to CSV migrations only (aligning with PR objectives)
  • Prioritizes source errors over destination errors
  • Uses getMessage() to get clean error messages without stack traces
src/Appwrite/Migration/Version/V23.php (1)

67-72: Good error handling for attribute creation.

The try-catch block properly handles potential failures during attribute creation and provides informative warning messages. This ensures the migration continues even if attribute creation fails.

@github-actions
Copy link
github-actions bot commented Jun 1, 2025

✨ Benchmark results

  • Requests per second: 895
  • Requests with 200 status code: 161,210
  • P99 latency: 0.210592766

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 895 1,119
200 161,210 201,496
P99 0.210592766 0.168723626

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: 1

🧹 Nitpick comments (1)
src/Appwrite/Utopia/Response/Model/Migration.php (1)

7-7: Avoid name shadowing – alias the imported class.

Appwrite\Utopia\Response\Model\Document already exists in the current namespace. Importing Utopia\Database\Document without an alias hides the local class and makes the code harder to reason about.

-use Utopia\Database\Document;
+use Utopia\Database\Document as DatabaseDocument;

Follow-up: update the method signature and return type accordingly (see next comment).

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0487fae and d01f1c1.

📒 Files selected for processing (1)
  • src/Appwrite/Utopia/Response/Model/Migration.php (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Appwrite/Utopia/Response/Model/Migration.php (1)
src/Appwrite/Utopia/Response/Model/Document.php (1)
  • Document (8-97)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan

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: 1

🧹 Nitpick comments (1)
src/Appwrite/Utopia/Response/Model/Migration.php (1)

112-139: Consider returning DatabaseDocument for consistency with other models

Other model filters (Document::filter, User::filter, etc.) return DatabaseDocument.
Aligning the return type here would keep the public API symmetric and help static analysers.

-    public function filter(Document $document): Document
+    public function filter(DatabaseDocument $document): DatabaseDocument

(Requires importing Utopia\Database\Document as DatabaseDocument or similar.)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d01f1c1 and 227c4fd.

📒 Files selected for processing (1)
  • src/Appwrite/Utopia/Response/Model/Migration.php (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Appwrite/Utopia/Response/Model/Migration.php (1)
src/Appwrite/Utopia/Response/Model/Document.php (1)
  • Document (8-97)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan

@abnegate abnegate merged commit 5d62613 into 1.8.x Jun 17, 2025
38 checks passed
@ItzNotABug ItzNotABug deleted the add-readable-error branch October 22, 2025 05:25
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.

3 participants

0