{"record":{"id":"1fc49302e201e246","repo":"appwrite/appwrite","slug":"response","errorCode":null,"errorMessage":"$response","messagePattern":"\\$response","errorType":"exception","errorClass":"Appwrite\\Auth\\OAuth2\\Exception","httpStatus":null,"severity":"error","filePath":"src/Appwrite/Auth/OAuth2.php","lineNumber":227,"sourceCode":"        \\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);\n        \\curl_setopt($ch, CURLOPT_HEADER, 0);\n        \\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n        \\curl_setopt($ch, CURLOPT_USERAGENT, 'Appwrite OAuth2');\n\n        if (!empty($payload)) {\n            \\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);\n            $headers[] = 'Content-length: ' . \\strlen($payload);\n        }\n\n        \\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n\n        // Send the request & save response to $response\n        $response = \\curl_exec($ch);\n\n        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n\n        if ($code >= 400) {\n            throw new Exception($response, $code);\n        }\n\n        return (string)$response;\n    }\n}\n","sourceCodeStart":209,"sourceCodeEnd":233,"githubUrl":"https://github.com/appwrite/appwrite/blob/feb9831e60c12102a2c75891715c7401d0f9a89c/src/Appwrite/Auth/OAuth2.php#L209-L233","documentation":"Thrown by GET /v1/functions when the `queries` parameter cannot be parsed or executed. The endpoint parses each query string with Query::parseQueries, then runs find()/count() against the 'functions' collection; a QueryException at either stage (src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php:108) is re-thrown as general_query_invalid. Only attributes whitelisted in the Functions queries validator (Functions::ALLOWED_ATTRIBUTES) may be filtered, searched, or sorted on.","triggerScenarios":"Calling functions.list with a hand-written query string that uses an unknown method or malformed quoting (e.g. 'filter(\"enabled\", true)'), filtering/sorting on an attribute outside the allowed list for functions, mixing a query method the database adapter does not support, or exceeding APP_LIMIT_ARRAY_PARAMS_SIZE queries.","commonSituations":"Building query strings by string concatenation instead of using the SDK Query helpers; copying a query example from a different endpoint (e.g. documents) whose attributes do not exist on functions; SDK/server version skew where an older SDK emits syntax the server rejects.","solutions":["Build queries with the SDK's Query class (e.g. Query.equal('enabled', true)) instead of hand-written strings","Filter and sort only on attributes documented as allowed for the functions list endpoint (Functions::ALLOWED_ATTRIBUTES)","Parse-test the exact query strings with the server SDK's Query::parseQueries equivalent before sending","Align the SDK major version with the Appwrite server version so generated query syntax matches"],"exampleFix":"// before (hand-written, unknown method)\nfunctions.list({ queries: ['filter(\"enabled\", true)'] });\n\n// after (SDK query builder)\nconst { Query } = require('node-appwrite');\nfunctions.list({ queries: [Query.equal('enabled', true)] });","handlingStrategy":"validation","validationCode":"const METHODS = ['equal','notEqual','contains','startsWith','endsWith','greaterThan','greaterThanEqual','lessThan','lessThanEqual','search','isNull','isNotNull','orderAsc','orderDesc','limit','offset','cursorAfter','cursorBefore'];\nconst ALLOWED = ['name','enabled','runtime','schedule','timeout','deploymentId','entrypoint','$id','$createdAt','$updatedAt']; // per endpoint docs\nfunction assertValidQueries(queries: string[]): void {\n  for (const q of queries) {\n    const method = q.split('(')[0];\n    if (!METHODS.includes(method)) throw new Error(`Unknown query method: ${method}`);\n    if (!/order|limit|offset|cursor/.test(method) && !ALLOWED.some((a) => q.includes(`\"${a}\"`))) {\n      throw new Error(`Attribute not filterable on functions: ${q}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await functions.list({ queries });\n} catch (e) {\n  if (e instanceof AppwriteException && e.code === 'general_query_invalid') {\n    // log e.message (it names the malformed query), fix the query builder input, retry once\n  } else throw e;\n}","preventionTips":["Always generate queries via the SDK's Query helpers rather than string concatenation","Cross-check every filtered/sorted attribute against the endpoint's documented allowed list","Keep the SDK major version in sync with the Appwrite server"],"tags":["appwrite","functions","query","pagination","api"],"backgroundTag":"invalid-query-syntax","analyzedSha":"feb9831e60c12102a2c75891715c7401d0f9a89c","analyzedAt":"2026-08-18T21:34:56.994Z","contentChangedAt":"2026-08-18T21:34:56.994Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}