Commit Graph

160 Commits

Author SHA1 Message Date
ArnabChatterjee20k ef4b9c4934 updated 2026-04-27 17:16:17 +05:30
ArnabChatterjee20k 340ce9d56b Add tests for channel conversion and event handling in Messaging
- Implement `test_convert_channels_rewrites_account_action_suffixes` to ensure
  that account action suffixes are correctly rewritten to user-scoped channels.
- Add `test_convert_channels_drops_account_actions_for_guest` to verify that
  account actions are dropped for guests without a user ID.
- Introduce `test_from_payload_does_not_suffix_account_for_nested_user_events`
  to confirm that nested user events do not leak action suffixes onto account channels.
2026-04-27 16:40:15 +05:30
Chirag Aggarwal d2230f8fe7 chore: bump PHPStan to level 4 and fix all new errors
Raises `phpstan.neon` level from 3 to 4 and fixes the 549 new errors
that level 4 surfaces across 157 files. Fixes are root-cause — no
`@phpstan-ignore`, no `@var` casts, no baseline entries, no widened
types. A handful of latent bugs were fixed along the way:

- `app/controllers/general.php`: path-traversal guard was negating
  `\substr(...)` before the strict comparison (`!\substr(...) === $base`
  was always `false === $base`). Rewritten as `\substr(...) !== $base`.
- `src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php`
  and `.../TablesDB/Logs/XList.php`: were importing the raw Matomo
  `DeviceDetector` (whose `getDevice()` returns `?int`) but treating the
  result as an array with `deviceName/deviceBrand/deviceModel` keys.
  Swapped to `Appwrite\Detector\Detector`, matching the wrapper already
  used a few lines below for `$os`/`$client`.
- `src/Appwrite/Platform/Modules/Functions/Workers/Builds.php`: a match
  key was checking `$resourceKey === 'functions'` when `$resourceKey`
  is `'functionId'|'siteId'` — always false. Switched to the intended
  `$resource->getCollection() === 'functions'` check.
- `src/Appwrite/OpenSSL/OpenSSL.php`: `encrypt()` return type tightened
  to `string|false` to match `openssl_encrypt`; this lets callers'
  `=== false` error handling remain meaningful.
- `app/controllers/api/messaging.php`: removed a dead
  `array_key_exists('from', [])` branch in the Msg91 provider (empty
  array literal; branch was unreachable).

Large cleanup categories across the 549 fixes:
- Removed redundant `?? default` on array offsets and expressions that
  PHPStan now knows are non-nullable.
- Removed unreachable statements (mostly `return;` after `throw` or
  `markTestSkipped()`).
- Removed redundant `is_array`/`is_string`/`is_bool`/`instanceof` checks
  on already-narrowed types.
- Added `default =>` arms (or throwing arms) to non-exhaustive matches
  on `string`/`mixed` input.
- Removed dead `$document === false` branches where method return types
  were tightened to non-nullable `Document`.
- Removed unused properties (`$version` on Etsy/Zoom OAuth2, `$paths` on
  Installer State, `$source` on MigrationsWorker, `$account2` on two
  GraphQL auth tests), unused traits (`ApiVectorsDB`, `DatabaseFixture`),
  and an unused `cleanupStaleExecutions` task method.
- Replaced `assertTrue(true)` and redundant `assertIsArray`/`assertIsString`/
  `assertNotNull` assertions with `addToAssertionCount(1)` or
  `assertNotEmpty` where the runtime type was already known.
2026-04-19 17:31:20 +05:30
ArnabChatterjee20k 6d9b787816 updated string replacement 2026-04-15 17:38:21 +05:30
ArnabChatterjee20k 7b8fb409b1 added database filtering 2026-04-15 17:33:57 +05:30
ArnabChatterjee20k 1fb78115e8 added backward compat 2026-04-15 17:23:18 +05:30
Matej Bačo a144968d70 Fix formatting 2026-04-08 12:08:32 +02:00
Parth Bhardwaj 2f5a49a37d Merge branch '1.9.x' into fix-10923-realtime-atomic-payload 2026-04-08 13:39:54 +05:30
bhardwajparth51 2c1813198d Simplify comments in Realtime E2E test 2026-04-03 22:12:24 +05:30
bhardwajparth51 912ea37af6 Address review feedback: Remove redundant Realtime triggers, correctly reorder hydration, and add E2E tests 2026-04-03 22:07:24 +05:30
Prem Palanisamy 52981e0164 fix: restore full CI matrix and revert test/endpoint changes to 1.9.x 2026-04-02 10:09:36 +02:00
Prem Palanisamy 25d9891f2b fix: use email probe in JSON export test, format fixes, add requireAdapter skips to Databases VectorsDB/DocumentsDB tests 2026-04-02 04:39:56 +02:00
Prem Palanisamy 8c9f9c6f58 fix: inherit project shared tables for separate pools, skip cross-engine migration tests 2026-04-02 02:05:10 +02:00
Prem Palanisamy c322cc3ffe Merge remote-tracking branch 'origin/1.9.x' into bump-database-version
# Conflicts:
#	src/Appwrite/Event/Message/Usage.php
2026-04-01 17:34:13 +02:00
Prem Palanisamy 7f9ce1ca85 Merge remote-tracking branch 'origin/1.9.x' into bump-database-version 2026-04-01 07:37:57 +02:00
Prem Palanisamy 168166b9c1 bump utopia-php/database to 5.3.19 and fix shared-mode CI failures
- Bump utopia-php/database from 5.3.17 to 5.3.19

- Remove invalid (int) cast on tenant sequence in shared tables mode

- Fix DSN construction for documentsdb/vectorsdb: filter empty strings
  from explode(), skip pool filtering when shared tables env vars unset,
  fail fast when no pool found

- Use dedicated mode for separate database pools in getDatabasesDB
  since shared tables can't work across engines (PostgreSQL integer
  _tenant vs MongoDB UUID tenant). Auto-init schema on first use.

- Add documentsdb/vectorsdb shared tables env vars to CI workflow

- Fix testChannelTablesDBRowUpdate race condition with deterministic
  event drain loop
2026-03-31 21:24:22 +02:00
ArnabChatterjee20k c7907932e4 Revert "Revert "Documentsdb + vectordb (latest)"" 2026-03-19 20:30:42 +05:30
ArnabChatterjee20k 9917f95dfd Revert "Documentsdb + vectordb (latest)" 2026-03-19 19:18:27 +05:30
ArnabChatterjee20k 8d58383c2e Merge remote-tracking branch 'origin/1.8.x' into sync-mongodb 2026-03-18 11:38:37 +05:30
Jake Barnby 06c5a2845f fix: restore deployment polling timeout in Realtime testChannelExecutions
The timeout parameters were accidentally removed in daaf1d7f77, causing
the assertEventually to use the default timeout which is too short for
deployment builds in CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 01:30:55 +13:00
Jake Barnby daaf1d7f77 fix: revert test polling timeouts to original values
The root cause (PostgreSQL duplicate index race condition) has been
fixed in the database library, so the timeout workarounds are no
longer needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 21:00:36 +13:00
Jake Barnby 04bbc30e7e fix: move attribute setup outside Swoole coroutine to prevent fatal errors
The assertEventually call inside Coroutine\run() causes a fatal PHP
error (exit 255) when it times out, killing the entire test process.
Moving DB/collection/attribute setup and polling outside the coroutine
ensures PHPUnit can properly handle assertion failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:55:14 +13:00
Jake Barnby 48c9ecb53f fix: increase all Realtime test polling timeouts to 240s for CI stability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:12:48 +13:00
Jake Barnby 341aabb942 fix: handle PostgreSQL race condition in shared mode project creation
PostgreSQL adapter throws non-Duplicate exceptions when a table/index
already exists during concurrent createCollection. Catch Throwable and
attempt metadata-only creation as fallback. Also increase Realtime
coroutine attribute polling timeout from 30s to 60s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 11:29:53 +13:00
ArnabChatterjee20k 681d930da3 renamed vectordb to vectordb 2026-03-09 13:51:48 +05:30
ArnabChatterjee20k e84a26be76 Merge remote-tracking branch 'origin/1.8.x' into sync-mongodb 2026-03-05 12:11:44 +05:30
loks0n cf7710b580 perf: reduce WebSocket timeout in realtime tests from 45s to 2s
Realtime E2E tests were taking 24+ minutes due to intentional timeout waits. Many tests verify event filtering by expecting a TimeoutException, and each was waiting 45 seconds.

Changes:
- Reduce default WebSocket timeout from 45s to 2s in RealtimeBase
- Add optional timeout parameter to getWebsocket() methods
- Use longer timeouts (5-10s) for tests that legitimately wait for slow operations (function executions, test channel events)
- Use named parameters for improved readability

Performance impact:
- Before: 24:07 minutes (1,447 seconds)
- After: 1:09 minutes (69 seconds)
- Speedup: ~21x faster

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-03 22:47:28 +00:00
ArnabChatterjee20k 05a2f56945 updated tests 2026-03-02 14:27:54 +05:30
ArnabChatterjee20k 3d4f37c482 refactor: improve channel handling for Realtime events and update tests for TablesDB compatibility 2026-03-02 14:12:13 +05:30
ArnabChatterjee20k 3287ef6a57 Merge remote-tracking branch 'origin/1.8.x' into sync-mongodb 2026-02-26 16:33:56 +05:30
ArnabChatterjee20k a57d970840 Add support for tablesdb in event generation and realtime channels 2026-02-25 18:58:33 +05:30
ArnabChatterjee20k 905763e755 added tests 2026-02-25 16:08:40 +05:30
Jake Barnby 9a97694a19 fix: resolve flaky E2E tests for realtime, avatars, migrations, and GraphQL
- Realtime: Use getLastEmailByAddress with userId probe instead of getLastEmail
  to prevent email race conditions in parallel execution; add status assertions
  on verification/recovery PUT responses for clearer failure diagnostics
- Avatars: Wrap external URL image fetches in assertEventually to retry
  transient network failures from appwrite.io
- Migrations: Increase performMigrationSync timeout from 10s to 60s
- GraphQL: Increase attribute polling timeouts from 60s to 120s with 500ms
  intervals to accommodate PostgreSQL under CI load

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:51:22 +13:00
Jake Barnby bada1a7c05 Timing updates 2026-02-24 14:00:07 +13:00
Jake Barnby 64a368ba3d Merge remote-tracking branch 'origin/feat-db-tests' into feat-mongodb
# Conflicts:
#	.github/workflows/tests.yml
#	src/Appwrite/Utopia/Response.php
#	src/Appwrite/Utopia/Response/Model/AttributeList.php
#	tests/e2e/Client.php
#	tests/e2e/Scopes/ProjectCustom.php
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/Transactions/TransactionsBase.php
#	tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php
#	tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php
#	tests/e2e/Services/Messaging/MessagingBase.php
#	tests/e2e/Services/Sites/SitesBase.php
#	tests/e2e/Services/Sites/SitesCustomServerTest.php
2026-02-18 03:27:23 +13:00
Jake Barnby 2e9c1b4745 fix: Remove @depends chains from Realtime tests for parallel execution
- Add helper methods createCollectionWithAttribute(), createTableWithAttribute(),
  createCollectionWithIndex(), createTableWithIndex() to RealtimeConsoleClientTest
- Add createTeam() helper to RealtimeCustomClientTest
- Replace all @depends annotations with direct helper method calls
- Enable tests to run in parallel with --functional flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 04:28:12 +13:00
Jake Barnby e70739a3c0 Merge remote-tracking branch 'origin/1.8.x' into feat-mongodb
# Conflicts:
#	Dockerfile
#	app/controllers/api/account.php
#	app/controllers/api/avatars.php
#	app/controllers/api/console.php
#	app/controllers/api/projects.php
#	app/controllers/api/storage.php
#	app/controllers/api/teams.php
#	app/http.php
#	app/init/database/filters.php
#	app/init/registers.php
#	app/init/resources.php
#	app/views/install/compose.phtml
#	composer.json
#	composer.lock
#	docker-compose.yml
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Update.php
#	src/Appwrite/Platform/Modules/Functions/Http/Deployments/XList.php
#	src/Appwrite/Platform/Tasks/Install.php
#	tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
2026-02-05 01:01:03 +13:00
Jake Barnby d4694ff8af Merge remote-tracking branch 'origin/1.8.x' into feat-db-tests
# Conflicts:
#	composer.json
#	composer.lock
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
#	tests/e2e/Services/Realtime/RealtimeCustomClientTest.php
2026-02-04 19:49:09 +13:00
ArnabChatterjee20k aa3d66df7b Merge branch 'new-pool-adapter' into documents-db-api 2026-01-22 12:34:22 +05:30
ArnabChatterjee20k ba82aab563 Merge remote-tracking branch 'origin/1.8.x' into documents-db-api 2026-01-19 13:22:53 +05:30
Jake Barnby 8335e43eaa Merge branch '1.8.x' into feat-db-tests 2026-01-19 18:34:35 +13:00
ArnabChatterjee20k 069e4c6001 Merge remote-tracking branch 'origin/1.8.x' into new-pool-adapter 2026-01-19 11:03:32 +05:30
Jake Barnby 714b8d7ea6 Migrate to PHPUnit 11 2026-01-15 16:14:53 +13:00
ArnabChatterjee20k 881d96a653 linting 2025-12-24 19:06:34 +05:30
ArnabChatterjee20k 39cf207df9 re 2025-12-24 18:57:58 +05:30
ArnabChatterjee20k f7668e0411 * added concurrent traffic load tests for realtime
* added assert eventual case for project console
* linting
2025-12-24 13:41:31 +05:30
ArnabChatterjee20k b7e2606b9f Enhance Realtime functionality with query support and improve tests
- Updated Realtime adapter to handle queries during subscription.
- Added query filtering capabilities in RuntimeQuery class.
- Modified RealtimeBase and RealtimeCustomClientTest to support query parameters in WebSocket connections.
- Improved test coverage for account and database channels with queries.
2025-12-22 18:01:00 +05:30
ArnabChatterjee20k d2c9ac079a Refactor VectorDB Embeddings API and Update Dimension Handling
- Updated the Create.php file to streamline the embedding creation process by removing unnecessary authentication checks and simplifying the parameter structure.
- Changed the parameter from 'documents' to 'texts' for clarity and adjusted the embedding model handling.
- Modified the response model to include error handling for embedding generation.
- Updated the Embedding response model to reflect changes in dimension naming and added error message handling.
- Refactored VectorDBCollection model to replace 'dimensions' with 'dimension' for consistency across the codebase.
- Adjusted all relevant tests to accommodate the new parameter names and response structures, ensuring comprehensive coverage for the updated functionality.
2025-12-02 14:20:25 +05:30
Jake Barnby 2776925540 Tests via console features 2025-11-25 21:11:01 +13:00
ArnabChatterjee20k bd6f62dd68 updated realtime, create endpoint , resources, registers 2025-11-06 17:48:39 +05:30