Back

AppwriteException: Invalid `permissions` param: Permissions must be an array of strings.

  • 0
  • Functions
  • Cloud
David.101
21 Dec, 2024, 10:48

I'm encountering an issue with the node-appwrite SDK while attempting to create a storage bucket with custom permissions. Despite following the official documentation, the permissions parameter is flagged as invalid when passed to the createBucket method.

Error:

Function failed: AppwriteException: Invalid permissions param: Permissions must be an array of strings. at _Client.call (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:278:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Storage.createBucket (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/services/storage.mjs:99:12) at async Module.default (file:///usr/local/server/src/function/src/main.js:72:13) at async execute (/usr/local/server/src/server.js:208:16) at async action (/usr/local/server/src/server.js:225:7) at async /usr/local/server/src/server.js:14:5

SDK Version: node-appwrite@14.1.0 Platform: Function executed in Appwrite server runtime

TypeScript
const permissions = [
    Permission.read(Role.user("6756fa35b98aaa8407ca")),
    Permission.write(Role.user("6756fa35b98aaa8407ca")),
    Permission.delete(Role.user("6756fa35b98aaa8407ca"))
];
console.log('Permissions:', permissions);

try {
    const bucket = await storage.createBucket(
        'uniqueBucketId',
        'My Bucket Name',
        'bucket',
        permissions
    );
    console.log('Bucket created:', bucket);
} catch (error) {
    console.error('Error:', error.message);
}

The permissions array seems valid when logged:

TypeScript
["read(\"user:6756fa35b98aaa8407ca\")","write(\"user:6756fa35b98aaa8407ca\")","delete(\"user:6756fa35b98aaa8407ca\")"]
TL;DR
Developers are encountering an error with the node-appwrite SDK while creating a storage bucket with custom permissions. The issue arises from passing an invalid parameter format; the permissions must be an array of strings. The provided permissions array includes more complex strings that result in rejection. To resolve this, convert the permissions array strings to simpler string values containing only the role ID.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more