Skip to content

fix(queries): reject search on attributes without a fulltext index - #13208

Merged
ChiragAgg5k merged 4 commits into
mainfrom
fix/reject-search-without-fulltext-index
Aug 14, 2026
Merged

ChiragAgg5k merged 4 commits into
mainfrom
fix/reject-search-without-fulltext-index

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

What

Query::search() on an attribute without a fulltext index returns a 500 instead of a 4xx. Four issues in Sentry, ~3400 events, oldest first seen 2025-05-19.

Sentry Endpoint Attribute Events
CLOUD-3590 functions.list name 1948
CLOUD-3MGV proxy.listRules domain 1265
CLOUD-3MHY sites.listLogs requestPath 166
CLOUD-3Q30 functions.listVariables key 2

Why

The endpoint query validators do not know about collection indexes, so these searches pass request validation. Database::find() revalidates them against the stored collection metadata and throws Utopia\Database\Exception\Query. The endpoints only caught that exception while parsing the query strings, allowing the database exception to escape as a 500.

Change

Catch QueryException around the find() and count() calls and return GENERAL_QUERY_INVALID, matching the document list endpoint.

This PR updates the three affected Appwrite endpoints:

  • src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php
  • src/Appwrite/Platform/Modules/Functions/Http/Variables/XList.php
  • src/Appwrite/Platform/Modules/Proxy/Http/Rules/XList.php

sites.listLogs now lives in the Cloud repository. Its handler was updated on the matching fix/reject-search-without-fulltext-index branch.

The dedicated search parameter remains unaffected because it searches the indexed synthetic search attribute.

Tests

Added E2E coverage asserting that each reported query returns HTTP 400 with general_query_invalid:

  • functions.list searching name
  • functions.listVariables searching key
  • proxy.listRules searching domain
  • sites.listLogs searching requestPath (Cloud branch)

Checks

  • composer lint on the changed Appwrite handlers and tests
  • composer analyze on the changed Appwrite handlers and tests
  • Pint and php -l on the changed Cloud handler and test

The E2E tests require the Appwrite and Cloud stacks and were not run locally.

Search queries require a fulltext index on the attribute. The system
collection validators never knew about indexes, so a search on any
unindexed attribute passed validation and was rejected later inside
Database::find() as a QueryException the list endpoints do not catch,
surfacing to callers as a 500.

Extend the base validator from IndexedQueries and pass the collection's
indexes, so the query is rejected during param validation with the
attribute named, matching what the user-collection document path
already does.

Only the synthetic 'search' attribute carries a fulltext index, and it
stays valid where a validator allows it.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR converts database-level query validation failures in three list endpoints into the established general_query_invalid client response.

  • Adds QueryException handling around Functions, Variables, and Proxy Rules database lookups and counts.
  • Moves the Proxy Rules count into the guarded query block.
  • Adds end-to-end coverage for searches on attributes without full-text indexes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php Translates query validation failures from function list lookup and count operations into the existing invalid-query API error.
src/Appwrite/Platform/Modules/Functions/Http/Variables/XList.php Applies the same invalid-query translation to function-variable list lookup and count operations.
src/Appwrite/Platform/Modules/Proxy/Http/Rules/XList.php Guards rule lookup and count with invalid-query handling while preserving subsequent certificate enrichment.
tests/e2e/Services/Functions/FunctionsConsoleClientTest.php Verifies that searching the unindexed variable key attribute returns HTTP 400 and general_query_invalid.
tests/e2e/Services/Functions/FunctionsCustomServerTest.php Verifies that searching the unindexed function name attribute returns the expected client error.
tests/e2e/Services/Proxy/ProxyBase.php Verifies that searching the unindexed proxy-rule domain attribute returns the expected client error.

Reviews (4): Last reviewed commit: "fix(tests): call variables endpoint dire..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/reject-search-without-fulltext-index (after).

Metric Before After Change
🚀 Requests/sec 206.44 205.77 ⚪ -0.3%
⏱️ Latency P50 69.41 ms 70.4 ms ⚪ +1.4%
⏱️ Latency P95 238.83 ms 238.33 ms ⚪ -0.2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 70.4 238.33 12,768 205.77 -0.5
Account 127.69 304.94 672 11.24 -27.58
TablesDB 67.57 222.44 6,944 113.04 +6.25
Storage 63.29 227.56 3,360 56.9 +3.01
Functions 107.47 273.14 1,792 30.81 -6.42

Top API waits (after)

API request Max wait (ms)
functions.variables.delete 775.89
tablesdb.rows.get 693.95
tablesdb.rows.create 620.74
storage.buckets.delete 561.91
account.prefs.update 554.49

@ChiragAgg5k
ChiragAgg5k merged commit 8170c2d into main Aug 14, 2026
44 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/reject-search-without-fulltext-index branch August 14, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants