Skip to content

feat(adapters): add appwrite adapter#3

Merged
cersho merged 4 commits into
mainfrom
cersho/feat-add-appwrite-adapter
Jun 13, 2026
Merged

feat(adapters): add appwrite adapter#3
cersho merged 4 commits into
mainfrom
cersho/feat-add-appwrite-adapter

Conversation

@cersho

@cersho cersho commented Jun 13, 2026

Copy link
Copy Markdown
Owner

No description provided.

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gofiles-sdk-web Ready Ready Preview, Comment Jun 13, 2026 11:51pm

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cersho, we couldn't start this review because you've reached your PR review rate limit.

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 @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 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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 84432c08-691e-4281-aeb1-36985530cbcd

📥 Commits

Reviewing files that changed from the base of the PR and between 69d80e0 and 0227824.

📒 Files selected for processing (3)
  • providers/appwrite/appwrite.go
  • providers/appwrite/appwrite_test.go
  • providers/appwrite/resumable.go
📝 Walkthrough

Walkthrough

Adds 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 Content-Range uploads. The new provider is registered in the catalog, tested with an httptest server, and documented in MDX.

Changes

Appwrite Storage Adapter

Layer / File(s) Summary
Provider catalog registration
provider_catalog.go, provider_catalog_test.go
Adds the appwrite slug and ProviderEnvSpec (required project ID, API key, optional endpoint) to the exported Providers map and ProviderNames slice; updates the catalog coverage test.
Adapter types, constructor, and capabilities
providers/appwrite/appwrite.go
Defines Options and Adapter structs; implements New with required-field validation, env-variable fallbacks, endpoint normalization, and default HTTP client selection; wires Name, Raw, Bucket, and Capabilities with explicit capability flags (progress/resumable supported; signed URLs and server-side copy not supported).
Core storage operations
providers/appwrite/appwrite.go
Implements Upload with progress-wrapping and multipart streaming, Download/Head/Exists via the download endpoint, Delete, Copy (download-then-reupload), List with cursor/prefix pagination, public-only URL, and SignedUploadURL returning a provider-level error.
Internal HTTP plumbing, error handling, and helpers
providers/appwrite/appwrite.go
Adds getFile, fetchDownload, uploadReader (io.Pipe + goroutine multipart), request (header merge, status validation, JSON decode), addHeaders, Appwrite-to-SDK error translation structs and codeForStatus/mapAppwriteError, validateFileID, metadata/result converters, query serialization helpers, and small utilities.
Resumable upload driver
providers/appwrite/resumable.go
Implements ResumableUpload entry point (API key enforcement, option validation); resumableDriver with Begin, Adopt, Probe, UploadPart (Content-Range + X-Appwrite-ID headers), Complete, Abort; plus sessionSizeWith, upsertPart, first, and firstInt64 helpers.
Tests and documentation
providers/appwrite/appwrite_test.go, apps/web/content/docs/adapters/appwrite.mdx, apps/web/content/docs/adapters/meta.json
Adds a full test suite (constructor validation, HTTP contracts, error mapping, resumable chunking/abort/adopt, API key gating, malformed multipart handling) and MDX adapter documentation with environment variable reference, public URL and resumable upload sections, limitations, and a compatibility table.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A new bucket to hop, a new place to store,
Appwrite joins the warren with uploads galore!
Chunked parts and Content-Range, byte by byte it flies,
Multipart streams through pipes beneath the server skies.
The catalog grows — one more entry on the list,
No signed URL? No problem! This bunny won't be missed. 🗄️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided, but the changeset is self-evident from the title and file changes (a complete Appwrite adapter implementation). Add a brief description explaining the purpose of the Appwrite adapter and any key features or limitations to help reviewers understand the scope.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new Appwrite adapter to the project.
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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
providers/appwrite/appwrite_test.go (1)

337-337: Using httptest.NewRequestWithContext aligns with Go best practices, but isn't currently enforced in CI.

The codebase runs go vet in CI, not golangci-lint. The noctx check is a golangci-lint rule and is not active in this repository's validation pipeline. While using httptest.NewRequestWithContext(context.Background(), ...) is a good practice and the context package 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

📥 Commits

Reviewing files that changed from the base of the PR and between 58b1d5c and 69d80e0.

📒 Files selected for processing (7)
  • apps/web/content/docs/adapters/appwrite.mdx
  • apps/web/content/docs/adapters/meta.json
  • provider_catalog.go
  • provider_catalog_test.go
  • providers/appwrite/appwrite.go
  • providers/appwrite/appwrite_test.go
  • providers/appwrite/resumable.go

Comment thread providers/appwrite/appwrite.go
Comment thread providers/appwrite/resumable.go Outdated
@cersho cersho merged commit 2d2221d into main Jun 13, 2026
7 checks passed
@cersho cersho deleted the cersho/feat-add-appwrite-adapter branch June 13, 2026 23:52
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