Closed
Description
👟 Reproduction steps
When I attempt to output a list of collections for an existing database, the Swift SDK crashes.
func listCollections() async throws {
do {
let collectionList = try await self.databases.listCollections( //crashes here
databaseId: databaseId //databaseId is valid. Works with let database = try await databases.get(...
)
collectionList.collections.forEach { collection in
print(collection)
}
} catch {
print(error)
}
}
.listCollections crashes to this code located within Sources>AppwriteModel>Collection.swift
public static func from(map: [String: Any] ) -> Collection {
return Collection(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
permissions: map["$permissions"] as! [String],
databaseId: map["databaseId"] as! String,
name: map["name"] as! String,
enabled: map["enabled"] as! Bool,
documentSecurity: map["documentSecurity"] as! Bool,
attributes: map["attributes"] as! [AnyCodable], // CRASHES ON THIS LINE
indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) }
)
}
error thrown
Could not cast value of type '__NSDictionaryI' (0x14201ac90) to 'JSONCodable.AnyCodable' (0x107cca460).
This is what is being returned from the server. Perhaps the [3] = "default" : (no summary) may have something to do with it? A default value is optional

👍 Expected behavior
It should output the list of collections without crashing.
👎 Actual Behavior
It crashes when .listCollections is called
🎲 Appwrite version
Different version (specify in environment)
💻 Operating system
MacOS
🧱 Your Environment
macOS 15.4.1
XCode 16.3
sdk-for-swift 9.0
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done