Back

Issue: Invalid document structure: Unknown attribute: "workspace"

  • 0
  • Cloud
lively-ops
8 Jan, 2025, 12:54

I have two collections: workspaces and workspace_membership. The workspaces collection has a one-to-many relationship. When I attempt to add a member to the workspace document via the workspace_membership collection, I receive an error message:

Here’s the schema for the workspace_membership collection:

TypeScript
{
  "$id": "workspace_membership",
  "$createdAt": "2025-01-08T08:54:55.354+00:00",
  "$updatedAt": "2025-01-08T08:54:55.354+00:00",
  "$permissions": [],
  "databaseId": "dbid123",
  "name": "workspace_membership",
  "enabled": true,
  "documentSecurity": false,
  "attributes": [
    {
      "key": "user_id",
      "type": "string",
      "status": "available",
      "error": "",
      "required": true,
      "array": false
    },
    {
      "key": "role",
      "type": "string",
      "status": "available",
      "error": "",
      "required": true,
      "array": false,
      "elements": ["OWNER", "ADMIN", "MEMBER", "GUEST", "VIEWER"],
      "format": "enum",
      "default": null
    },
    {
      "key": "status",
      "type": "string",
      "status": "available",
      "error": "",
      "required": true,
      "array": false,
      "elements": ["INVITED", "ACTIVE", "EXPIRED", "REVOKED"],
      "format": "enum",
      "default": null
    },
    {
      "key": "invited_at",
      "type": "string",
      "status": "available",
      "error": "",
      "required": false,
      "array": false
    },
    {
      "key": "accepted_at",
      "type": "string",
      "status": "available",
      "error": "",
      "required": false,
      "array": false
    },
    {
      "key": "workspace_id",
      "type": "string",
      "status": "available",
      "error": "",
      "required": true,
      "array": false
    }
  ],
  "indexes": []
}

What should I do to resolve this issue and correctly link the member to the workspace document?

Note: This issue only occurs when I try to add a member to a workspace. All other relationships are working fine.

TL;DR
The error "Invalid document structure: Unknown attribute: 'workspace'" occurs when trying to add a member to a workspace document via the workspace_membership collection. To resolve this, ensure that the attribute "workspace" is correctly referenced in the workspace document structure. Double-check the schema and relationships between the workspaces and workspace_membership collections to correctly link the member to the workspace document.
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