feat(adapters): add appwrite adapter#3
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 48 minutes and 12 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a complete Appwrite storage adapter to the Go files SDK. The implementation covers core CRUD operations (upload, download, head, exists, delete, copy, list), public URL generation, and a resumable upload driver with chunked ChangesAppwrite Storage Adapter
Sequence Diagram(s)sequenceDiagram
participant Client as files.Client
participant Adapter as appwrite.Adapter
participant UploadReader as uploadReader goroutine
participant AppwriteAPI as Appwrite REST API
rect rgba(70, 130, 180, 0.5)
note over Client,AppwriteAPI: Standard Upload
Client->>Adapter: Upload(ctx, key, body, opts)
Adapter->>Adapter: validateFileID(key)
Adapter->>UploadReader: pipe reader + multipart writer
UploadReader->>AppwriteAPI: POST /storage/buckets/{bucket}/files (multipart)
AppwriteAPI-->>Adapter: appwriteFile JSON → UploadResult
end
rect rgba(60, 179, 113, 0.5)
note over Client,AppwriteAPI: Resumable Upload
Client->>Adapter: ResumableUpload(ctx, key, opts)
Adapter->>Adapter: validate API key + options
Adapter-->>Client: resumableDriver
loop each chunk
Client->>Adapter: UploadPart(partNum, data)
Adapter->>AppwriteAPI: POST with Content-Range + X-Appwrite-ID headers
AppwriteAPI-->>Adapter: appwriteFile (partial or final)
end
Client->>Adapter: Complete(parts)
Adapter-->>Client: UploadResult
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
providers/appwrite/appwrite_test.go (1)
337-337: Usinghttptest.NewRequestWithContextaligns with Go best practices, but isn't currently enforced in CI.The codebase runs
go vetin CI, not golangci-lint. Thenoctxcheck is a golangci-lint rule and is not active in this repository's validation pipeline. While usinghttptest.NewRequestWithContext(context.Background(), ...)is a good practice and thecontextpackage is already imported, this change is optional rather than required for merge.Suggested improvement
- req := httptest.NewRequest(http.MethodPost, "/", body) + req := httptest.NewRequestWithContext(context.Background(), http.MethodPost, "/", body)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@providers/appwrite/appwrite_test.go` at line 337, At line 337 in providers/appwrite/appwrite_test.go, the httptest.NewRequest call can be improved by using httptest.NewRequestWithContext with context.Background() as the first argument instead of httptest.NewRequest. Since the context package is already imported, update the call to pass context.Background() as the first parameter, shifting the existing arguments (http.MethodPost, "/", body) to positions 2-4. This aligns with Go best practices even though it is not currently enforced by the repository's CI pipeline.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@providers/appwrite/appwrite.go`:
- Around line 420-446: In the query function, the struct field used for the
attribute parameter is incorrectly named "Attribute" with JSON tag "attribute",
but the Appwrite Storage API expects "column" instead. Change the struct field
name from Attribute to Column and update its JSON tag from "attribute,omitempty"
to "column,omitempty". Additionally, update the conditional assignment statement
where payload.Attribute is set to instead set payload.Column. This fix in the
query function will ensure all query helper functions (queryLimit,
queryCursorAfter, queryStartsWith) correctly format requests for the Appwrite
API.
In `@providers/appwrite/resumable.go`:
- Around line 103-105: The Abort method in the resumableDriver type is
discarding the error returned by d.adapter.Delete() on the line where it
captures the result with a blank identifier, which causes the method to always
return nil even if the Delete operation fails. Instead of ignoring the error,
capture the return value from d.adapter.Delete() in a named variable and return
that error directly from the Abort method, so that any cleanup failures are
properly propagated to the caller.
---
Nitpick comments:
In `@providers/appwrite/appwrite_test.go`:
- Line 337: At line 337 in providers/appwrite/appwrite_test.go, the
httptest.NewRequest call can be improved by using httptest.NewRequestWithContext
with context.Background() as the first argument instead of httptest.NewRequest.
Since the context package is already imported, update the call to pass
context.Background() as the first parameter, shifting the existing arguments
(http.MethodPost, "/", body) to positions 2-4. This aligns with Go best
practices even though it is not currently enforced by the repository's CI
pipeline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 13de9e14-f898-4bc9-a1fc-e37bbd66ef22
📒 Files selected for processing (7)
apps/web/content/docs/adapters/appwrite.mdxapps/web/content/docs/adapters/meta.jsonprovider_catalog.goprovider_catalog_test.goproviders/appwrite/appwrite.goproviders/appwrite/appwrite_test.goproviders/appwrite/resumable.go
No description provided.