{"record":{"id":"01a2b422fa62f6a9","repo":"toeverything/AFFiNE","slug":"query-too-long-01a2b4","errorCode":"query_too_long","errorMessage":"Query is too long, max length is ${max}.","messagePattern":"Query is too long, max length is (.+?)\\.","errorType":"http","errorClass":"QueryTooLong","httpStatus":400,"severity":"error","filePath":"packages/backend/server/src/core/workspaces/resolvers/member.ts","lineNumber":200,"sourceCode":"  @ResolveField(() => [InviteUserType], {\n    description: 'Members of workspace',\n    complexity: 2,\n  })\n  async members(\n    @CurrentUser() user: CurrentUser,\n    @Parent() workspace: WorkspaceType,\n    @Args('skip', { type: () => Int, nullable: true }) skip?: number,\n    @Args('take', { type: () => Int, nullable: true }) take?: number,\n    @Args('query', { type: () => String, nullable: true }) query?: string\n  ) {\n    await this.ac\n      .user(user.id)\n      .workspace(workspace.id)\n      .assert('Workspace.Users.Read');\n\n    if (query) {\n      if (query.length > 255) {\n        throw new QueryTooLong({ max: 255 });\n      }\n\n      const list = await this.models.workspaceUser.search(workspace.id, query, {\n        offset: skip ?? 0,\n        first: take ?? 8,\n      });\n\n      return list.map(({ status, type, user }) => ({\n        ...user,\n        permission: Number(type),\n        role: Number(type),\n        inviteId: user?.id ?? '',\n        status,\n      }));\n    } else {\n      const [list] = await this.models.workspaceUser.paginate(workspace.id, {\n        offset: skip ?? 0,\n        first: take ?? 8,","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/packages/backend/server/src/core/workspaces/resolvers/member.ts#L182-L218","documentation":"Thrown by the members resolver when the optional query argument exceeds 255 characters. The member search is bounded to keep query cost predictable; longer strings are rejected before hitting the workspaceUser.search model. Reported with code query_too_long (HTTP 400, invalid_input).","triggerScenarios":"Querying the members field of a workspace with a query string longer than 255 characters.","commonSituations":"A search box bound directly to the query arg without a max-length attribute; pasting a long blob/email list into the member search; a debounced search that accumulates whitespace.","solutions":["Truncate the query to <= 255 characters before sending the GraphQL request.","Add maxlength=255 (and client truncation) to the member-search input.","If you need member filtering by multiple emails, use a different/batched API rather than one long query."],"exampleFix":"// before\nmembers(workspace, { query: longString });\n// after\nmembers(workspace, { query: longString.slice(0, 255) });","handlingStrategy":"validation","validationCode":"const MAX_QUERY = 255;\nfunction sanitizeMemberQuery(q: string | undefined): string | undefined {\n  if (!q) return q;\n  return q.length > MAX_QUERY ? q.slice(0, MAX_QUERY) : q;\n}\n// before the query\nconst q = sanitizeMemberQuery(rawQuery);","typeGuard":"function isWithinQueryLimit(q: string | undefined, max = 255): boolean {\n  return !q || q.length <= max;\n}","tryCatchPattern":null,"preventionTips":["Set maxlength=255 on the member search input.","Trim and cap the query client-side before sending.","Do not stuff multiple emails into the search query; use a dedicated batch API."],"tags":["graphql","validation","workspace","search"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}