Skip to content

feat: Apple SDK update for version 14.1.0#100

Merged
abnegate merged 4 commits into
mainfrom
dev
Feb 13, 2026
Merged

feat: Apple SDK update for version 14.1.0#100
abnegate merged 4 commits into
mainfrom
dev

Conversation

@ArnabChatterjee20k
Copy link
Copy Markdown
Member

@ArnabChatterjee20k ArnabChatterjee20k commented Feb 13, 2026

This PR contains updates to the Apple SDK for version 14.1.0.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 13, 2026

Walkthrough

This pull request introduces API key management functionality to the Appwrite Swift SDK. It adds five new public methods to the Account service (listKeys, createKey, getKey, updateKey, deleteKey) with corresponding model classes (Key, KeyList) and a new Scopes enum. The Channel routing system is refactored to use optional IDs instead of required IDs with default values, with minor API surface changes to helper methods. Two new OAuth providers (githubImagine, googleImagine) are added to OAuthProvider enum. Documentation examples are provided for all five key management operations. The README compatibility note is updated from version 1.8.x to latest.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (4 files):

⚔️ README.md (content)
⚔️ Sources/Appwrite/Channel.swift (content)
⚔️ Sources/Appwrite/Services/Account.swift (content)
⚔️ Sources/AppwriteEnums/OAuthProvider.swift (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
Title check ❓ Inconclusive The title 'feat: Apple SDK update for version 14.1.0' is vague and generic, using broad terms like 'update' that don't convey meaningful information about the specific changes included in the PR. Replace with a more specific title that highlights the main feature, such as 'feat: Add account key management API and update realtime channels' to better describe the primary changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch dev
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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.

Copy link
Copy Markdown

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
README.md (1)

5-10: ⚠️ Potential issue | 🟡 Minor

Version compatibility string "latest" is vague and inconsistent with the badge on Line 5.

Line 10 now says "compatible with Appwrite server version latest," which doesn't tell users which actual server version this SDK targets. Meanwhile, the badge on Line 5 still reads api%20version-1.8.1. If the server version has changed, the badge should be updated too; if it hasn't, Line 10 should state the concrete version (e.g., 1.8.x).

Since this SDK is auto-generated, this may be intentional from the generator—but it's worth flagging as it degrades the developer experience.

Sources/Appwrite/Channel.swift (1)

70-76: ⚠️ Potential issue | 🟠 Major

_Func and _Execution marker structs have no extensions — these channels are dead-ends.

Every other marker type in the file has extensions enabling method chaining or terminal actions:

  • _Databasecollection(), _Collectiondocument(), etc. (chaining)
  • _Document, _Row, _File, _Team, _Membershipcreate() (terminal actions)

However, _Func and _Execution have no extensions at all. This means:

  • Channel.function("id") returns a RealtimeChannel<_Func> with only toString() available
  • Channel.execution("id") returns a RealtimeChannel<_Execution> with only toString() available

If these are intentional (i.e., these channels are only for subscribing to all events at that level without further refinement), that's fine. Otherwise, this is a regression — _Func should likely have an .execution() chaining method, and _Execution should have a create() terminal action to match the established pattern.

🤖 Fix all issues with AI agents
In `@docs/examples/account/create-key.md`:
- Around line 11-15: The example uses an empty string for the optional expire
parameter in the account.createKey call which can trigger backend validation
errors; update the example to either omit the expire argument entirely or pass
nil explicitly (i.e., change the expire: "" to either remove the expire line or
use expire: nil) so it matches the function signature expire: String? = nil and
avoids sending an invalid empty string.

In `@docs/examples/account/update-key.md`:
- Around line 11-16: The example call to account.updateKey uses an invalid empty
string for the optional expire parameter; update the example to either omit the
expire argument entirely or pass nil (since expire: String? = nil expects an ISO
8601 date when provided). Locate the account.updateKey invocation in the example
and remove the expire line or change it from "" to nil so the example matches
the function signature and avoids backend validation errors.

In `@Sources/Appwrite/Services/Organizations.swift`:
- Around line 38-40: Fix the two doc-comment typos where "it's" is used as a
possessive: change the comment "Get a billing address using it's ID." to "Get a
billing address using its ID." and change the other comment containing "it's
payment method ID" to "its payment method ID"; locate these strings in
Sources/Appwrite/Services/Organizations.swift to update the doc comments (they
appear immediately above the corresponding billing-address and payment-method
related API methods).

In `@Sources/AppwriteEnums/OAuthProvider.swift`:
- Around line 43-44: The OAuthProvider enum contains invalid cases githubImagine
and googleImagine; remove these two cases from the OAuthProvider enum (or
replace/rename them to valid Appwrite identifiers if they were intentionally
meant to represent real providers) and, if they are intentional custom/upcoming
providers, insert them alphabetically next to their base providers (e.g., place
githubImagine immediately after github and googleImagine immediately after
google) while ensuring the enum raw values match the intended provider
identifiers; update any references to OAuthProvider.githubImagine or
OAuthProvider.googleImagine accordingly.

In `@Sources/AppwriteModels/BillingAddress.swift`:
- Around line 18-19: Update the misleading doc comment for the `id` property on
the `BillingAddress` model: replace "Region ID" with a clearer description such
as "Billing address ID" (or "Billing address identifier") in the
`BillingAddress` struct/class so the documentation accurately reflects that `id`
refers to the billing address identifier; ensure the comment sits immediately
above `public let id: String` and matches style of other model comments.

In `@Sources/AppwriteModels/PaymentMethod.swift`:
- Around line 44-45: The documentation for the property userId in
PaymentMethod.swift is wrong ("ID of the Team"); update the doc comment above
the public let userId: String declaration to accurately describe the property
(e.g., "ID of the User" or "User identifier associated with the payment method")
so the comment matches the userId property in the PaymentMethod type.
- Around line 64-65: The documentation comment for the PaymentMethod property
named `default` contains an HTML entity (&#039;) instead of a plain apostrophe;
update the doc comment on the `default` property in the PaymentMethod type
(PaymentMethod.swift) to use a normal apostrophe (') so the comment reads "True
when it's the default payment method." and ensure no other HTML entities remain
in that doc string.
- Around line 190-212: The call site in PaymentMethod.from(map:) uses the
reserved Swift keyword default as an argument label without backticks, causing a
compile error; update the argument label to use backticks to match the
initializer (i.e., call the initializer inside from(map:) with `default` as the
label), keeping the rest of the mapped casts (e.g., id, createdAt,
providerMethodId, expired, failed) unchanged; also scan other constructors for
similar unbackticked uses of default and fix them the same way.

In `@Sources/AppwriteModels/UsageResources.swift`:
- Around line 4-5: The doc comment above the class is inconsistent with the
class name: change the comment text "UsageResource" to match the class
identifier `UsageResources` (or alternatively rename the class to
`UsageResource` if the singular form is intended); update the comment that
documents the `UsageResources` class so the wording and identifier are
consistent with the class name.
🧹 Nitpick comments (4)
Sources/Appwrite/Channel.swift (1)

103-104: Inconsistent nil-to-wildcard coalescing across route helpers.

collection() and table() coalesce nil to "*" before calling next(), so the ID segment is always present in the path:

  • Channel.database("db").collection()"databases.db.collections.*"

In contrast, document(), row(), and file() pass nil through, so next() omits the ID segment entirely:

  • Channel.database("db").collection().document()"databases.db.collections.*.documents"

This appears intentional (intermediate vs. leaf nodes), but the divergent behavior from a uniform String? = nil signature could surprise consumers. A brief doc comment on each method clarifying the nil-id semantics would help.

Also applies to: 110-111, 119-120, 126-127, 135-136

Sources/Appwrite/Services/Organizations.swift (1)

31-36: Minor formatting: extra whitespace before closing parenthesis on line 35.

📝 Proposed fix
         return try await client.call(
             method: "DELETE",
             path: apiPath,
             headers: apiHeaders,
-            params: apiParams        )
+            params: apiParams
+        )
docs/examples/account/delete-billing-address.md (1)

10-12: Consider using a more descriptive variable name for consistency.

While result is functional, other examples in this PR use descriptive variable names (e.g., key, paymentMethod, billingAddressList). Consider renaming to maintain consistency across documentation, though the generic name may be acceptable if the delete operation doesn't return meaningful data.

📝 Suggested naming improvement
-let result = try await account.deleteBillingAddress(
+let _ = try await account.deleteBillingAddress(
     billingAddressId: "<BILLING_ADDRESS_ID>"
 )

Or if a response is returned:

-let result = try await account.deleteBillingAddress(
+let response = try await account.deleteBillingAddress(
     billingAddressId: "<BILLING_ADDRESS_ID>"
 )
Sources/AppwriteEnums/Scopes.swift (1)

1-1: Unnecessary import Foundation.

The Scopes enum only uses String and CustomStringConvertible, both from the Swift standard library. Foundation is not needed here.

♻️ Suggested fix
-import Foundation
-
 public enum Scopes: String, CustomStringConvertible {

Comment thread docs/examples/account/create-key.md Outdated
Comment thread docs/examples/account/update-key.md Outdated
Comment on lines +38 to +40
///
/// Get a billing address using it's ID.
///
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo in doc comment: "it's" → "its" (possessive).

Same issue on line 154: "it's payment method ID" should be "its payment method ID".

📝 Proposed fix
-    /// Get a billing address using it's ID.
+    /// Get a billing address using its ID.

And on line 154:

-    /// Get an organization's payment method using it's payment method ID.
+    /// Get an organization's payment method using its payment method ID.
📝 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
///
/// Get a billing address using it's ID.
///
///
/// Get a billing address using its ID.
///
🤖 Prompt for AI Agents
In `@Sources/Appwrite/Services/Organizations.swift` around lines 38 - 40, Fix the
two doc-comment typos where "it's" is used as a possessive: change the comment
"Get a billing address using it's ID." to "Get a billing address using its ID."
and change the other comment containing "it's payment method ID" to "its payment
method ID"; locate these strings in
Sources/Appwrite/Services/Organizations.swift to update the doc comments (they
appear immediately above the corresponding billing-address and payment-method
related API methods).

Comment on lines +43 to +44
case githubImagine = "githubImagine"
case googleImagine = "googleImagine"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for githubImagine and googleImagine in the repository
rg -n "githubImagine|googleImagine" -i

# Check the full context of the OAuthProvider enum
cat -n Sources/AppwriteEnums/OAuthProvider.swift

# Search for any comments or documentation about these providers
rg -n "Imagine" -B2 -A2

Repository: appwrite/sdk-for-apple

Length of output: 2357


🌐 Web query:

Appwrite OAuth providers githubImagine googleImagine official documentation

💡 Result:

In Appwrite Auth, the official docs show that GitHub and Google are supported OAuth2 providers (use provider values github and google when calling the OAuth session/token endpoints, after enabling the provider in the Appwrite Console). [1]

For the Google provider setup, Appwrite’s official integration guide walks through creating a Google OAuth client, adding the Client ID/secret in Auth → Settings → OAuth2 Providers → Google, and configuring the redirect URI. [2]

If “githubImagine / googleImagine” refers to something specific beyond the GitHub/Google OAuth providers, it doesn’t appear as an official Appwrite term in the docs I found. [1]

Sources:
[1] Appwrite Account API Reference (Create OAuth2 session/token; supported providers list)
[2] Appwrite “OAuth with Google” integration guide


Remove or verify these invalid OAuth provider identifiers.

githubImagine and googleImagine are not valid Appwrite OAuth provider identifiers. According to official Appwrite documentation, only github and google are supported providers. These enum cases will fail at runtime if used. Additionally, if they are intentional (e.g., custom or upcoming providers), they should be inserted in alphabetical order between their respective base providers rather than appended at the end (e.g., githubImagine after github, googleImagine after google).

🤖 Prompt for AI Agents
In `@Sources/AppwriteEnums/OAuthProvider.swift` around lines 43 - 44, The
OAuthProvider enum contains invalid cases githubImagine and googleImagine;
remove these two cases from the OAuthProvider enum (or replace/rename them to
valid Appwrite identifiers if they were intentionally meant to represent real
providers) and, if they are intentional custom/upcoming providers, insert them
alphabetically next to their base providers (e.g., place githubImagine
immediately after github and googleImagine immediately after google) while
ensuring the enum raw values match the intended provider identifiers; update any
references to OAuthProvider.githubImagine or OAuthProvider.googleImagine
accordingly.

Comment on lines +18 to +19
/// Region ID
public let id: String
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Misleading doc comment: "Region ID" should describe a billing address ID.

The id property on BillingAddress is documented as "Region ID", which appears to be a copy-paste artifact from another model. Consider updating to "Billing address ID" or similar.

Proposed fix
-    /// Region ID
+    /// Billing address ID
     public let id: String
🤖 Prompt for AI Agents
In `@Sources/AppwriteModels/BillingAddress.swift` around lines 18 - 19, Update the
misleading doc comment for the `id` property on the `BillingAddress` model:
replace "Region ID" with a clearer description such as "Billing address ID" (or
"Billing address identifier") in the `BillingAddress` struct/class so the
documentation accurately reflects that `id` refers to the billing address
identifier; ensure the comment sits immediately above `public let id: String`
and matches style of other model comments.

Comment on lines +44 to +45
/// ID of the Team.
public let userId: String
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Incorrect doc comment: "ID of the Team" for userId.

This appears to be a copy-paste error. The property is userId but the comment says "ID of the Team."

Proposed fix
-    /// ID of the Team.
+    /// User ID.
     public let userId: String
📝 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
/// ID of the Team.
public let userId: String
/// User ID.
public let userId: String
🤖 Prompt for AI Agents
In `@Sources/AppwriteModels/PaymentMethod.swift` around lines 44 - 45, The
documentation for the property userId in PaymentMethod.swift is wrong ("ID of
the Team"); update the doc comment above the public let userId: String
declaration to accurately describe the property (e.g., "ID of the User" or "User
identifier associated with the payment method") so the comment matches the
userId property in the PaymentMethod type.

Comment on lines +64 to +65
/// True when it&#039;s the default payment method.
public let `default`: Bool
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

HTML entity in doc comment.

Line 64 contains &#039; instead of an apostrophe. Consider using a plain ' for readability.

Proposed fix
-    /// True when it&#039;s the default payment method.
+    /// True when it's the default payment method.
📝 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
/// True when it&#039;s the default payment method.
public let `default`: Bool
/// True when it's the default payment method.
public let `default`: Bool
🤖 Prompt for AI Agents
In `@Sources/AppwriteModels/PaymentMethod.swift` around lines 64 - 65, The
documentation comment for the PaymentMethod property named `default` contains an
HTML entity (&#039;) instead of a plain apostrophe; update the doc comment on
the `default` property in the PaymentMethod type (PaymentMethod.swift) to use a
normal apostrophe (') so the comment reads "True when it's the default payment
method." and ensure no other HTML entities remain in that doc string.

Comment on lines +190 to +212
public static func from(map: [String: Any] ) -> PaymentMethod {
return PaymentMethod(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
permissions: map["$permissions"] as! [String],
providerMethodId: map["providerMethodId"] as! String,
clientSecret: map["clientSecret"] as! String,
providerUserId: map["providerUserId"] as! String,
userId: map["userId"] as! String,
expiryMonth: map["expiryMonth"] as! Int,
expiryYear: map["expiryYear"] as! Int,
last4: map["last4"] as! String,
brand: map["brand"] as! String,
name: map["name"] as! String,
mandateId: map["mandateId"] as! String,
country: map["country"] as! String,
state: map["state"] as! String,
lastError: map["lastError"] as! String,
default: map["default"] as! Bool,
expired: map["expired"] as! Bool,
failed: map["failed"] as! Bool
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Potential compile error: default keyword needs backticks at call site.

On line 209, default: is used as an argument label without backticks. Since default is a reserved keyword in Swift, this will fail to compile. The initializer parameter on line 89 correctly uses `default`, and the call site must match.

Proposed fix
-            default: map["default"] as! Bool,
+            `default`: map["default"] as! Bool,
#!/bin/bash
# Check if there are other call sites with the same issue
rg -n 'default:' --type=swift -g '!**/CodingKeys*' | grep -v '`default`' | grep -v '//' | grep -v 'case'
🤖 Prompt for AI Agents
In `@Sources/AppwriteModels/PaymentMethod.swift` around lines 190 - 212, The call
site in PaymentMethod.from(map:) uses the reserved Swift keyword default as an
argument label without backticks, causing a compile error; update the argument
label to use backticks to match the initializer (i.e., call the initializer
inside from(map:) with `default` as the label), keeping the rest of the mapped
casts (e.g., id, createdAt, providerMethodId, expired, failed) unchanged; also
scan other constructors for similar unbackticked uses of default and fix them
the same way.

Comment on lines +4 to +5
/// UsageResource
open class UsageResources: Codable {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Doc comment/class name mismatch: "UsageResource" vs UsageResources.

The doc comment says "UsageResource" (singular) while the class is named UsageResources (plural). Minor inconsistency.

🤖 Prompt for AI Agents
In `@Sources/AppwriteModels/UsageResources.swift` around lines 4 - 5, The doc
comment above the class is inconsistent with the class name: change the comment
text "UsageResource" to match the class identifier `UsageResources` (or
alternatively rename the class to `UsageResource` if the singular form is
intended); update the comment that documents the `UsageResources` class so the
wording and identifier are consistent with the class name.

Copy link
Copy Markdown

@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

🤖 Fix all issues with AI agents
In `@Sources/Appwrite/Services/Account.swift`:
- Around line 355-359: The enum arrays (e.g., scopes: [AppwriteEnums.Scopes])
are being passed raw into apiParams and stringify incorrectly; update the
callers to convert enum arrays to arrays of raw strings (e.g., scopes.map {
$0.rawValue }) before inserting into apiParams in createKey, createSession and
Avatars.getFavicon (or change those apiParams entries to accept [String]? like
createOAuth2Session does) so buildJSON sees standard [String] types; locate the
apiParams construction in Account.createKey, Account.createSession and
Avatars.getFavicon and replace the enum array values with their .map {
$0.rawValue } equivalents.

Comment thread Sources/Appwrite/Services/Account.swift Outdated
Comment on lines +355 to +359
let apiParams: [String: Any?] = [
"name": name,
"scopes": scopes,
"expire": expire
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# First, let's check the overall structure
echo "=== Repository structure ==="
find . -type f -name "*.swift" | head -20

# Check Account.swift around lines 355-359
echo -e "\n=== Account.swift lines 355-359 ==="
fd "Account.swift" -x wc -l {} | head -1
fd "Account.swift" -x sed -n '350,370p' {}

# Look for the createKey method to understand the full context
echo -e "\n=== Account.swift createKey method ==="
fd "Account.swift" -x sed -n '338,376p' {}

Repository: appwrite/sdk-for-apple

Length of output: 2916


🏁 Script executed:

#!/bin/bash

# Find and examine Scopes enum definition
echo "=== Looking for Scopes enum ==="
rg -n "enum Scopes" --type swift -B2 -A10

# Look for AppwriteEnums file
echo -e "\n=== AppwriteEnums file ==="
fd "Enums\.swift|AppwriteEnums\.swift" --exec wc -l {}

Repository: appwrite/sdk-for-apple

Length of output: 776


🏁 Script executed:

#!/bin/bash

# Check Client.swift buildBody implementation
echo "=== Client.swift buildBody method ==="
rg -n "func buildBody" --type swift -A20

# Look for any JSONSerialization or encoder logic
echo -e "\n=== JSONSerialization handling ==="
rg -n "JSONSerialization" --type swift -B2 -A5

Repository: appwrite/sdk-for-apple

Length of output: 6523


🏁 Script executed:

#!/bin/bash

# Check createOAuth2Session to compare how it handles scopes
echo "=== Looking for createOAuth2Session ==="
rg -n "createOAuth2Session" --type swift -B5 -A20

# Check for RawRepresentable handling or enum extensions
echo -e "\n=== RawRepresentable handling ==="
rg -n "RawRepresentable" --type swift -B2 -A10

# Look for any enum to string conversion logic
echo -e "\n=== Enum to string conversion ==="
rg -n "rawValue" --type swift | grep -i scope | head -20

Repository: appwrite/sdk-for-apple

Length of output: 6749


🏁 Script executed:

#!/bin/bash

# Get the full buildJSON method implementation
echo "=== Client.swift buildJSON method (full) ==="
rg -n "private func buildJSON" --type swift -A40

# Also check if there's any parameter processing/encoding happening
echo -e "\n=== Parameter encoding logic ==="
rg -n "encodedParams\|encodeParams\|encode.*params" --type swift -B3 -A5

Repository: appwrite/sdk-for-apple

Length of output: 2932


🏁 Script executed:

#!/bin/bash

# Search for any Encodable or CodingStrategy for handling enums
echo "=== Encoding strategies or Encodable handling ==="
rg -n "JSONEncoder\|encode\|Encodable" --type swift | grep -E "(func|class|struct)" | head -20

# Check if there's any logic to convert arrays of enums
echo -e "\n=== Array handling in parameters ==="
rg -n "is \[" --type swift | grep -i param | head -10

# Look at the actual parameter passing in buildJSON
echo -e "\n=== Look for map or flatMap on params ==="
rg -n "map\|compactMap" --type swift | grep -i param | head -10

Repository: appwrite/sdk-for-apple

Length of output: 921


🏁 Script executed:

#!/bin/bash

# Let's get more context around line 530 to see the complete buildJSON
echo "=== Client.swift around buildJSON and JSONSerialization ==="
sed -n '500,550p' Sources/Appwrite/Client.swift

Repository: appwrite/sdk-for-apple

Length of output: 2048


🏁 Script executed:

#!/bin/bash

# Check if Scopes enum has Encodable conformance
echo "=== Full Scopes enum definition ==="
cat Sources/AppwriteEnums/Scopes.swift

# Check if there's a toJson() method for Encodable
echo -e "\n=== toJson() method implementation ==="
rg -n "func toJson\|extension.*Encodable" --type swift -A10

# Check if RawRepresentable enums have special handling
echo -e "\n=== Extensions on enums or RawRepresentable ==="
rg -n "extension.*enum\|RawRepresentable" --type swift -B2 -A8

Repository: appwrite/sdk-for-apple

Length of output: 432


🏁 Script executed:

#!/bin/bash

# Search for other enum array parameters in the SDK
echo "=== Other [AppwriteEnums.*] array parameters ==="
rg -n "\[AppwriteEnums\." --type swift | grep -v "case " | head -30

# Check buildMultipart to see if it has similar issue
echo -e "\n=== buildMultipart full implementation ==="
sed -n '535,650p' Sources/Appwrite/Client.swift

Repository: appwrite/sdk-for-apple

Length of output: 4552


🏁 Script executed:

#!/bin/bash

# Look at how createKey specifically is used/tested
echo "=== Tests or usage of createKey ==="
rg -n "createKey" --type swift -B2 -A5

Repository: appwrite/sdk-for-apple

Length of output: 705


Fix enum array serialization in createKey and other methods.

The scopes: [AppwriteEnums.Scopes] parameter passes an array of enums directly to apiParams. When buildJSON processes it (line 506-526), [AppwriteEnums.Scopes] does not match any whitelisted type and is not Encodable, so it falls through to String(describing: param), converting the array to a debug string like "[Scopes(...), Scopes(...)]" instead of a JSON array of raw values. This will fail during serialization.

The same issue affects:

  • createSession (line 425)
  • Avatars.getFavicon with permissions: [AppwriteEnums.BrowserPermission]?

Compare with createOAuth2Session (line 1798), which correctly uses scopes: [String]?. Convert enum arrays to string arrays using .map { $0.rawValue } before passing to apiParams.

🤖 Prompt for AI Agents
In `@Sources/Appwrite/Services/Account.swift` around lines 355 - 359, The enum
arrays (e.g., scopes: [AppwriteEnums.Scopes]) are being passed raw into
apiParams and stringify incorrectly; update the callers to convert enum arrays
to arrays of raw strings (e.g., scopes.map { $0.rawValue }) before inserting
into apiParams in createKey, createSession and Avatars.getFavicon (or change
those apiParams entries to accept [String]? like createOAuth2Session does) so
buildJSON sees standard [String] types; locate the apiParams construction in
Account.createKey, Account.createSession and Avatars.getFavicon and replace the
enum array values with their .map { $0.rawValue } equivalents.

@abnegate abnegate merged commit f3ed63d into main Feb 13, 2026
1 check passed
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.

2 participants