appwrite/appwrite · error · Appwrite\Auth\OAuth2\Exception
$response
Error message
$response
What it means
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.
Source
Thrown at src/Appwrite/Auth/OAuth2.php:227
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
\curl_setopt($ch, CURLOPT_HEADER, 0);
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, CURLOPT_USERAGENT, 'Appwrite OAuth2');
if (!empty($payload)) {
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$headers[] = 'Content-length: ' . \strlen($payload);
}
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Send the request & save response to $response
$response = \curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code >= 400) {
throw new Exception($response, $code);
}
return (string)$response;
}
}
View on GitHub (pinned to feb9831e60)
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
Example fix
// before (hand-written, unknown method)
functions.list({ queries: ['filter("enabled", true)'] });
// after (SDK query builder)
const { Query } = require('node-appwrite');
functions.list({ queries: [Query.equal('enabled', true)] }); Defensive patterns
Strategy: validation
Validate before calling
const METHODS = ['equal','notEqual','contains','startsWith','endsWith','greaterThan','greaterThanEqual','lessThan','lessThanEqual','search','isNull','isNotNull','orderAsc','orderDesc','limit','offset','cursorAfter','cursorBefore'];
const ALLOWED = ['name','enabled','runtime','schedule','timeout','deploymentId','entrypoint','$id','$createdAt','$updatedAt']; // per endpoint docs
function assertValidQueries(queries: string[]): void {
for (const q of queries) {
const method = q.split('(')[0];
if (!METHODS.includes(method)) throw new Error(`Unknown query method: ${method}`);
if (!/order|limit|offset|cursor/.test(method) && !ALLOWED.some((a) => q.includes(`"${a}"`))) {
throw new Error(`Attribute not filterable on functions: ${q}`);
}
}
} Try / catch
try {
const res = await functions.list({ queries });
} catch (e) {
if (e instanceof AppwriteException && e.code === 'general_query_invalid') {
// log e.message (it names the malformed query), fix the query builder input, retry once
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Query method '{$method}' is not supported in Realtime querie
- Collection {$from} not found
- general_cursor_not_found
- database_query_order_null
- general_cursor_not_found
AI-assisted analysis of appwrite/appwrite@feb9831e60 (2026-08-18).
Data as JSON: /api/errors/1fc49302e201e246.
Report an issue: GitHub.