Merge branch '1.9.x' into feat-project-password-policy

This commit is contained in:
Torsten Dittmann authored and GitHub committed 2026-06-02 13:28:34 +04:00
commit d0f02fd3fc
16 files changed
+410 -342

No files matched your search

+2 -2
View File
@@ -55,8 +55,8 @@ _APP_DB_PORT_DOCUMENTSDB=27017
_APP_DB_ADAPTER_VECTORSDB=postgresql
_APP_DB_HOST_VECTORSDB=postgresql
_APP_DB_PORT_VECTORSDB=5432
_APP_EMBEDDING_MODELS=embeddinggemma
_APP_EMBEDDING_ENDPOINT='http://ollama:11434/api/embed'
_APP_EMBEDDING_MODELS=nomic-embed-text
_APP_EMBEDDING_ENDPOINT='http://appwrite-embedding:3000/embed'
_APP_EMBEDDING_TIMEOUT=30000
_APP_STORAGE_DEVICE=Local
_APP_STORAGE_S3_ACCESS_KEY=
+210 -171
View File
@@ -786,125 +786,132 @@ Http::shutdown()
Http::shutdown()
->groups(['api'])
->inject('route')
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('queueForEvents')
->inject('auditContext')
->inject('publisherForAudits')
->inject('usage')
->inject('publisherForUsage')
->inject('publisherForFunctions')
->inject('queueForWebhooks')
->inject('queueForRealtime')
->inject('dbForProject')
->inject('authorization')
->inject('timelimit')
->inject('eventProcessor')
->inject('bus')
->inject('apiKey')
->inject('mode')
->action(function (Route $route, Request $request, Response $response, Document $project, User $user, Event $queueForEvents, AuditContext $auditContext, Audit $publisherForAudits, Context $usage, UsagePublisher $publisherForUsage, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject, Authorization $authorization, callable $timelimit, EventProcessor $eventProcessor, Bus $bus, ?Key $apiKey, string $mode) use ($parseLabel) {
->action(function (Route $route, Response $response, Document $project, Event $queueForEvents, FunctionPublisher $publisherForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject, EventProcessor $eventProcessor) {
if (empty($queueForEvents->getEvent())) {
return;
}
$responsePayload = $response->getPayload();
if (empty($queueForEvents->getPayload())) {
$queueForEvents->setPayload($response->getPayload());
}
if (! empty($queueForEvents->getEvent())) {
if (empty($queueForEvents->getPayload())) {
$queueForEvents->setPayload($responsePayload);
}
// Get project and function/webhook events (cached)
$functionsEvents = $eventProcessor->getFunctionsEvents($project, $dbForProject);
$webhooksEvents = $eventProcessor->getWebhooksEvents($project);
// Get project and function/webhook events (cached)
$functionsEvents = $eventProcessor->getFunctionsEvents($project, $dbForProject);
$webhooksEvents = $eventProcessor->getWebhooksEvents($project);
// Generate events for this operation
$generatedEvents = Event::generateEvents(
$queueForEvents->getEvent(),
$queueForEvents->getParams()
);
// Generate events for this operation
$generatedEvents = Event::generateEvents(
$queueForEvents->getEvent(),
$queueForEvents->getParams()
);
$allowedOnConsole = !empty(\array_intersect($route->getGroups(), Realtime::CONSOLE_ALLOWLIST));
if ($project->getId() !== 'console' || $allowedOnConsole) {
$queueForRealtime
->from($queueForEvents)
->trigger();
}
$allowedOnConsole = !empty(\array_intersect($route->getGroups(), Realtime::CONSOLE_ALLOWLIST));
if ($project->getId() !== 'console' || $allowedOnConsole) {
$queueForRealtime
->from($queueForEvents)
->trigger();
}
// Only trigger functions if there are matching function events
if (! empty($functionsEvents)) {
foreach ($generatedEvents as $event) {
if (isset($functionsEvents[$event])) {
$publisherForFunctions->enqueue(FunctionMessage::fromEvent(
event: $queueForEvents->getEvent(),
params: $queueForEvents->getParams(),
project: $queueForEvents->getProject(),
user: $queueForEvents->getUser(),
userId: $queueForEvents->getUserId(),
payload: $queueForEvents->getPayload(),
platform: $queueForEvents->getPlatform(),
));
break;
}
}
}
// Only trigger webhooks if there are matching webhook events
if (! empty($webhooksEvents)) {
foreach ($generatedEvents as $event) {
if (isset($webhooksEvents[$event])) {
$queueForWebhooks
->from($queueForEvents)
->trigger();
break;
}
// Only trigger functions if there are matching function events
if (! empty($functionsEvents)) {
foreach ($generatedEvents as $event) {
if (isset($functionsEvents[$event])) {
$publisherForFunctions->enqueue(FunctionMessage::fromEvent(
event: $queueForEvents->getEvent(),
params: $queueForEvents->getParams(),
project: $queueForEvents->getProject(),
user: $queueForEvents->getUser(),
userId: $queueForEvents->getUserId(),
payload: $queueForEvents->getPayload(),
platform: $queueForEvents->getPlatform(),
));
break;
}
}
}
$requestParams = $route->getParamsValues();
// Only trigger webhooks if there are matching webhook events
if (! empty($webhooksEvents)) {
foreach ($generatedEvents as $event) {
if (isset($webhooksEvents[$event])) {
$queueForWebhooks
->from($queueForEvents)
->trigger();
break;
}
}
}
});
/**
* Abuse labels
*/
Http::shutdown()
->groups(['api'])
->inject('route')
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('timelimit')
->action(function (Route $route, Request $request, Response $response, Document $project, User $user, callable $timelimit) {
$abuseEnabled = System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled';
$abuseResetCode = $route->getLabel('abuse-reset', []);
$abuseResetCode = \is_array($abuseResetCode) ? $abuseResetCode : [$abuseResetCode];
if ($abuseEnabled && \count($abuseResetCode) > 0 && \in_array($response->getStatusCode(), $abuseResetCode)) {
$abuseKeyLabel = $route->getLabel('abuse-key', 'url:{url},ip:{ip}');
$abuseKeyLabel = (! is_array($abuseKeyLabel)) ? [$abuseKeyLabel] : $abuseKeyLabel;
foreach ($abuseKeyLabel as $abuseKey) {
$start = $request->getContentRangeStart();
$end = $request->getContentRangeEnd();
$timeLimit = $timelimit($abuseKey, $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600));
$timeLimit
->setParam('{projectId}', $project->getId())
->setParam('{userId}', $user->getId())
->setParam('{userAgent}', $request->getUserAgent(''))
->setParam('{ip}', $request->getIP())
->setParam('{url}', $request->getHostname() . $route->getPath())
->setParam('{method}', $request->getMethod())
->setParam('{chunkId}', (int) ($start / ($end + 1 - $start)));
foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys
if (! empty($value)) {
$timeLimit->setParam('{param-' . $key . '}', (\is_array($value)) ? \json_encode($value) : $value);
}
}
$abuse = new Abuse($timeLimit);
$abuse->reset();
}
if (! $abuseEnabled || \count($abuseResetCode) === 0 || ! \in_array($response->getStatusCode(), $abuseResetCode)) {
return;
}
/**
* Audit labels
*/
$abuseKeyLabel = $route->getLabel('abuse-key', 'url:{url},ip:{ip}');
$abuseKeyLabel = (! is_array($abuseKeyLabel)) ? [$abuseKeyLabel] : $abuseKeyLabel;
foreach ($abuseKeyLabel as $abuseKey) {
$start = $request->getContentRangeStart();
$end = $request->getContentRangeEnd();
$timeLimit = $timelimit($abuseKey, $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600));
$timeLimit
->setParam('{projectId}', $project->getId())
->setParam('{userId}', $user->getId())
->setParam('{userAgent}', $request->getUserAgent(''))
->setParam('{ip}', $request->getIP())
->setParam('{url}', $request->getHostname() . $route->getPath())
->setParam('{method}', $request->getMethod())
->setParam('{chunkId}', (int) ($start / ($end + 1 - $start)));
foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys
if (! empty($value)) {
$timeLimit->setParam('{param-' . $key . '}', (\is_array($value)) ? \json_encode($value) : $value);
}
}
$abuse = new Abuse($timeLimit);
$abuse->reset();
}
});
Http::shutdown()
->groups(['api'])
->inject('route')
->inject('params')
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('auditContext')
->inject('publisherForAudits')
->inject('mode')
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, AuditContext $auditContext, Audit $publisherForAudits, string $mode) use ($parseLabel) {
$responsePayload = $response->getPayload();
$pattern = $route->getLabel('audits.resource', null);
if (! empty($pattern)) {
$resource = $parseLabel($pattern, $responsePayload, $requestParams, $user, $project);
$resource = $parseLabel($pattern, $responsePayload, $params, $user, $project);
if (! empty($resource) && $resource !== $pattern) {
$auditContext->resource = $resource;
}
@@ -951,97 +958,129 @@ Http::shutdown()
$publisherForAudits->enqueue(AuditMessage::fromContext($auditContext));
}
});
// Cache label
$useCache = $route->getLabel('cache', false);
if ($useCache) {
$resource = $resourceType = null;
$data = $response->getPayload();
$statusCode = $response->getStatusCode();
if (! empty($data['payload']) && $statusCode >= 200 && $statusCode < 300) {
$pattern = $route->getLabel('cache.resource', null);
if (! empty($pattern)) {
$resource = $parseLabel($pattern, $responsePayload, $requestParams, $user, $project);
}
Http::shutdown()
->groups(['api'])
->inject('route')
->inject('params')
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('dbForProject')
->inject('authorization')
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, Database $dbForProject, Authorization $authorization) use ($parseLabel) {
if (! $route->getLabel('cache', false)) {
return;
}
$pattern = $route->getLabel('cache.resourceType', null);
if (! empty($pattern)) {
$resourceType = $parseLabel($pattern, $responsePayload, $requestParams, $user, $project);
}
$data = $response->getPayload();
$statusCode = $response->getStatusCode();
if (empty($data['payload']) || $statusCode < 200 || $statusCode >= 300) {
return;
}
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId())
);
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId())
);
$key = $request->cacheIdentifier();
$signature = md5($data['payload']);
$now = DateTime::now();
$cacheLog = $authorization->skip(fn () => $dbForProject->getDocument('cache', $key));
$key = $request->cacheIdentifier();
$signature = md5($data['payload']);
// First request for this resource: record it and persist the payload.
if ($cacheLog->isEmpty()) {
// Resolve resource labels lazily — only needed when creating the entry.
$requestParams = [];
foreach ($route->getParams() as $paramKey => $param) {
$requestParams[$paramKey] = $params[$paramKey] ?? $request->getParam($paramKey, $param['default']);
}
$resourcePattern = $route->getLabel('cache.resource', null);
$resourceTypePattern = $route->getLabel('cache.resourceType', null);
try {
$authorization->skip(fn () => $dbForProject->createDocument('cache', new Document([
'$id' => $key,
'resource' => empty($resourcePattern) ? null : $parseLabel($resourcePattern, $data, $requestParams, $user, $project),
'resourceType' => empty($resourceTypePattern) ? null : $parseLabel($resourceTypePattern, $data, $requestParams, $user, $project),
'mimeType' => $response->getContentType(),
'accessedAt' => $now,
'signature' => $signature,
])));
$cache->save($key, $data['payload']);
return;
} catch (DuplicateException) {
// Race condition: another concurrent request already created the entry.
$cacheLog = $authorization->skip(fn () => $dbForProject->getDocument('cache', $key));
$accessedAt = $cacheLog->getAttribute('accessedAt', 0);
$now = DateTime::now();
if ($cacheLog->isEmpty()) {
try {
$authorization->skip(fn () => $dbForProject->createDocument('cache', new Document([
'$id' => $key,
'resource' => $resource,
'resourceType' => $resourceType,
'mimeType' => $response->getContentType(),
'accessedAt' => $now,
'signature' => $signature,
])));
} catch (DuplicateException) {
// Race condition: another concurrent request already created the cache document
$cacheLog = $authorization->skip(fn () => $dbForProject->getDocument('cache', $key));
}
} elseif (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_CACHE_UPDATE)) > $accessedAt) {
$cacheLog->setAttribute('accessedAt', $now);
$authorization->skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), new Document([
'accessedAt' => $cacheLog->getAttribute('accessedAt')
])));
// Overwrite the file every APP_CACHE_UPDATE seconds to update the file modified time that is used in the TTL checks in cache->load()
$cache->save($key, $data['payload']);
}
if ($signature !== $cacheLog->getAttribute('signature')) {
$cache->save($key, $data['payload']);
}
}
}
if ($project->getId() !== 'console') {
if (! $user->isPrivileged($authorization->getRoles())) {
$bus->dispatch(new RequestCompleted(
project: $project->getArrayCopy(),
request: $request,
response: $response,
));
}
// Existing entry: refresh the access time once per APP_CACHE_UPDATE window
// (keeps the file mtime current for TTL checks) and re-persist on content change.
$stale = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_CACHE_UPDATE)) > $cacheLog->getAttribute('accessedAt', 0);
if ($stale) {
$authorization->skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), new Document([
'accessedAt' => $now,
])));
}
// Publish usage metrics if context has data
if (! $usage->isEmpty()) {
$metrics = $usage->getMetrics();
if ($stale || $signature !== $cacheLog->getAttribute('signature')) {
$cache->save($key, $data['payload']);
}
});
// Filter out API key disabled metrics using suffix pattern matching
$disabledMetrics = $apiKey?->getDisabledMetrics() ?? [];
if (! empty($disabledMetrics)) {
$metrics = array_values(array_filter($metrics, function ($metric) use ($disabledMetrics) {
foreach ($disabledMetrics as $pattern) {
if (str_ends_with($metric['key'], $pattern)) {
return false;
}
Http::shutdown()
->groups(['api'])
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('usage')
->inject('publisherForUsage')
->inject('authorization')
->inject('bus')
->inject('apiKey')
->action(function (Request $request, Response $response, Document $project, User $user, Context $usage, UsagePublisher $publisherForUsage, Authorization $authorization, Bus $bus, ?Key $apiKey) {
if ($project->getId() === 'console') {
return;
}
if (! $user->isPrivileged($authorization->getRoles())) {
$bus->dispatch(new RequestCompleted(
project: $project->getArrayCopy(),
request: $request,
response: $response,
));
}
// Publish usage metrics if context has data
if (! $usage->isEmpty()) {
$metrics = $usage->getMetrics();
// Filter out API key disabled metrics using suffix pattern matching
$disabledMetrics = $apiKey?->getDisabledMetrics() ?? [];
if (! empty($disabledMetrics)) {
$metrics = array_values(array_filter($metrics, function ($metric) use ($disabledMetrics) {
foreach ($disabledMetrics as $pattern) {
if (str_ends_with($metric['key'], $pattern)) {
return false;
}
}
return true;
}));
}
$message = new UsageMessage(
project: $project,
metrics: $metrics,
reduce: $usage->getReduce()
);
$publisherForUsage->enqueue($message);
return true;
}));
}
$message = new UsageMessage(
project: $project,
metrics: $metrics,
reduce: $usage->getReduce()
);
$publisherForUsage->enqueue($message);
}
});
+3
View File
@@ -108,6 +108,9 @@ const APP_VCS_GITHUB_EMAIL = 'team@appwrite.io';
const APP_VCS_GITHUB_URL = 'https://github.com/TeamAppwrite';
const APP_BRANDED_EMAIL_BASE_TEMPLATE = 'email-base-styled';
// Embeddings
const APP_EMBEDDING_BATCH_LIMIT = 100;
/**
* JWT for Resource Tokens.
*/
+3 -3
View File
@@ -22,7 +22,7 @@ use Appwrite\Usage\Context as UsageContext;
use Appwrite\Utopia\Database\Documents\User;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Utopia\Agents\Adapters\Ollama;
use Utopia\Agents\Adapters\Appwrite as AppwriteAdapter;
use Utopia\Agents\Agent;
use Utopia\Audit\Adapter\Database as AdapterDatabase;
use Utopia\Audit\Audit;
@@ -1277,8 +1277,8 @@ return function (Container $context): void {
$context->set('deviceForBuilds', fn ($project, Telemetry $telemetry) => new Device\Telemetry($telemetry, getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId())), ['project', 'telemetry']);
$context->set('embeddingAgent', function ($register) {
$adapter = new Ollama();
$adapter->setEndpoint(System::getEnv('_APP_EMBEDDING_ENDPOINT', 'http://ollama:11434/api/embed'));
$adapter = new AppwriteAdapter();
$adapter->setEndpoint(System::getEnv('_APP_EMBEDDING_ENDPOINT', 'http://appwrite-embedding:3000/embed'));
$adapter->setTimeout((int) System::getEnv('_APP_EMBEDDING_TIMEOUT', '30000'));
return new Agent($adapter);
}, ['register']);
+6 -1
View File
@@ -18,6 +18,7 @@ use Utopia\Logger\Log;
use Utopia\Pools\Group;
use Utopia\Queue\Publisher;
use Utopia\Registry\Registry;
use Utopia\Span\Span;
use Utopia\Storage\Device\Telemetry as TelemetryDevice;
use Utopia\System\System;
use Utopia\Telemetry\Adapter as Telemetry;
@@ -55,7 +56,11 @@ return function (Container $container): void {
return $project;
}
return $dbForPlatform->getDocument('projects', $project->getId());
$project = $dbForPlatform->getDocument('projects', $project->getId());
Span::add('project.id', $project->getId());
return $project;
}, ['message', 'dbForPlatform']);
$container->set('dbForProject', fn (DatabaseFactory $databaseFactory, Document $project, Database $dbForPlatform) => $project->isEmpty() || $project->getId() === 'console'
+3 -3
View File
@@ -52,7 +52,7 @@
"appwrite/php-runtimes": "0.20.*",
"appwrite/php-clamav": "2.0.*",
"utopia-php/abuse": "1.3.*",
"utopia-php/agents": "1.2.*",
"utopia-php/agents": "2.*",
"utopia-php/analytics": "0.15.*",
"utopia-php/audit": "^2.4",
"utopia-php/auth": "0.5.*",
@@ -67,7 +67,7 @@
"utopia-php/emails": "0.7.*",
"utopia-php/dns": "1.7.*",
"utopia-php/dsn": "0.2.1",
"utopia-php/http": "2.0.0-rc3",
"utopia-php/http": "^2.0@RC",
"utopia-php/fetch": "^1.1",
"utopia-php/validators": "0.2.*",
"utopia-php/image": "0.8.*",
@@ -85,7 +85,7 @@
"utopia-php/registry": "0.5.*",
"utopia-php/storage": "2.*",
"utopia-php/system": "0.10.*",
"utopia-php/telemetry": "0.2.*",
"utopia-php/telemetry": "^0.4",
"utopia-php/vcs": "4.*",
"utopia-php/websocket": "1.0.*",
"matomo/device-detector": "6.4.*",
Generated
+63 -60
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "53a96b051328aa5572b1008496733f85",
"content-hash": "ec80b1465e57bc223903fa102249f216",
"packages": [
{
"name": "adhocore/jwt",
@@ -2712,16 +2712,16 @@
},
{
"name": "symfony/http-client",
"version": "v7.4.9",
"version": "v7.4.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
"reference": "7e941c6abf4e3bf7dca160bf0e11ef36a9f832f6"
"reference": "e8a112b8415707265a7e614278136a9d92989a6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/7e941c6abf4e3bf7dca160bf0e11ef36a9f832f6",
"reference": "7e941c6abf4e3bf7dca160bf0e11ef36a9f832f6",
"url": "https://api.github.com/repos/symfony/http-client/zipball/e8a112b8415707265a7e614278136a9d92989a6a",
"reference": "e8a112b8415707265a7e614278136a9d92989a6a",
"shasum": ""
},
"require": {
@@ -2789,7 +2789,7 @@
"http"
],
"support": {
"source": "https://github.com/symfony/http-client/tree/v7.4.9"
"source": "https://github.com/symfony/http-client/tree/v7.4.13"
},
"funding": [
{
@@ -2809,7 +2809,7 @@
"type": "tidelift"
}
],
"time": "2026-04-29T13:25:15+00:00"
"time": "2026-05-24T09:57:54+00:00"
},
{
"name": "symfony/http-client-contracts",
@@ -2980,16 +2980,16 @@
},
{
"name": "symfony/polyfill-php82",
"version": "v1.37.0",
"version": "v1.38.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php82.git",
"reference": "34808efe3e68f69685796f7c253a2f1d8ea9df59"
"reference": "002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/34808efe3e68f69685796f7c253a2f1d8ea9df59",
"reference": "34808efe3e68f69685796f7c253a2f1d8ea9df59",
"url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b",
"reference": "002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b",
"shasum": ""
},
"require": {
@@ -3036,7 +3036,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php82/tree/v1.37.0"
"source": "https://github.com/symfony/polyfill-php82/tree/v1.38.1"
},
"funding": [
{
@@ -3056,20 +3056,20 @@
"type": "tidelift"
}
],
"time": "2026-04-10T16:19:22+00:00"
"time": "2026-05-26T12:45:58+00:00"
},
{
"name": "symfony/polyfill-php83",
"version": "v1.37.0",
"version": "v1.38.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php83.git",
"reference": "3600c2cb22399e25bb226e4a135ce91eeb2a6149"
"reference": "8339098cae28673c15cce00d80734af0453054e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/3600c2cb22399e25bb226e4a135ce91eeb2a6149",
"reference": "3600c2cb22399e25bb226e4a135ce91eeb2a6149",
"url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/8339098cae28673c15cce00d80734af0453054e2",
"reference": "8339098cae28673c15cce00d80734af0453054e2",
"shasum": ""
},
"require": {
@@ -3116,7 +3116,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php83/tree/v1.37.0"
"source": "https://github.com/symfony/polyfill-php83/tree/v1.38.1"
},
"funding": [
{
@@ -3136,7 +3136,7 @@
"type": "tidelift"
}
],
"time": "2026-04-10T17:25:58+00:00"
"time": "2026-05-26T12:51:13+00:00"
},
{
"name": "symfony/polyfill-php85",
@@ -3411,16 +3411,16 @@
},
{
"name": "utopia-php/agents",
"version": "1.2.2",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/agents.git",
"reference": "0703f4cae02261e09a1bf0d39a4b1ce649cae634"
"reference": "c9785833948639c09c8ccc3e954178c66ed9a896"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/agents/zipball/0703f4cae02261e09a1bf0d39a4b1ce649cae634",
"reference": "0703f4cae02261e09a1bf0d39a4b1ce649cae634",
"url": "https://api.github.com/repos/utopia-php/agents/zipball/c9785833948639c09c8ccc3e954178c66ed9a896",
"reference": "c9785833948639c09c8ccc3e954178c66ed9a896",
"shasum": ""
},
"require": {
@@ -3458,9 +3458,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/agents/issues",
"source": "https://github.com/utopia-php/agents/tree/1.2.2"
"source": "https://github.com/utopia-php/agents/tree/2.1.0"
},
"time": "2026-05-08T10:38:23+00:00"
"time": "2026-05-29T10:44:54+00:00"
},
{
"name": "utopia-php/analytics",
@@ -3669,16 +3669,16 @@
},
{
"name": "utopia-php/circuit-breaker",
"version": "0.3.0",
"version": "0.3.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/circuit-breaker.git",
"reference": "064243c1667778c00abf027ff53a735a228776de"
"reference": "db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/circuit-breaker/zipball/064243c1667778c00abf027ff53a735a228776de",
"reference": "064243c1667778c00abf027ff53a735a228776de",
"url": "https://api.github.com/repos/utopia-php/circuit-breaker/zipball/db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828",
"reference": "db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828",
"shasum": ""
},
"require": {
@@ -3688,7 +3688,7 @@
"laravel/pint": "^1.29",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.0",
"utopia-php/telemetry": "0.2.*"
"utopia-php/telemetry": "^0.4"
},
"suggest": {
"ext-opentelemetry": "Required by utopia-php/telemetry when using OpenTelemetry metrics.",
@@ -3725,9 +3725,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/circuit-breaker/issues",
"source": "https://github.com/utopia-php/circuit-breaker/tree/0.3.0"
"source": "https://github.com/utopia-php/circuit-breaker/tree/0.3.1"
},
"time": "2026-05-12T04:27:08+00:00"
"time": "2026-05-29T12:12:23+00:00"
},
{
"name": "utopia-php/cli",
@@ -4346,16 +4346,16 @@
},
{
"name": "utopia-php/http",
"version": "2.0.0-rc3",
"version": "2.0.0-rc4",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/http.git",
"reference": "e1a51a2eb906a3d461378fb551a647ef01714f1c"
"reference": "0396a959c6a3be7c16b4b72283347327a75d1f92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/http/zipball/e1a51a2eb906a3d461378fb551a647ef01714f1c",
"reference": "e1a51a2eb906a3d461378fb551a647ef01714f1c",
"url": "https://api.github.com/repos/utopia-php/http/zipball/0396a959c6a3be7c16b4b72283347327a75d1f92",
"reference": "0396a959c6a3be7c16b4b72283347327a75d1f92",
"shasum": ""
},
"require": {
@@ -4363,7 +4363,7 @@
"utopia-php/compression": "0.1.*",
"utopia-php/di": "0.3.*",
"utopia-php/servers": "0.4.*",
"utopia-php/telemetry": "0.2.*",
"utopia-php/telemetry": "^0.4",
"utopia-php/validators": "0.2.*"
},
"require-dev": {
@@ -4396,9 +4396,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/http/issues",
"source": "https://github.com/utopia-php/http/tree/2.0.0-rc3"
"source": "https://github.com/utopia-php/http/tree/2.0.0-rc4"
},
"time": "2026-05-21T14:42:41+00:00"
"time": "2026-06-02T04:17:22+00:00"
},
{
"name": "utopia-php/image",
@@ -4976,25 +4976,26 @@
},
{
"name": "utopia-php/queue",
"version": "0.18.4",
"version": "0.18.6",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/queue.git",
"reference": "1323b52f39b899c580dbb7af8562fc53d4e13e62"
"reference": "954cd3788b37697b83fd2757adcd93422f21a846"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/1323b52f39b899c580dbb7af8562fc53d4e13e62",
"reference": "1323b52f39b899c580dbb7af8562fc53d4e13e62",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/954cd3788b37697b83fd2757adcd93422f21a846",
"reference": "954cd3788b37697b83fd2757adcd93422f21a846",
"shasum": ""
},
"require": {
"php": ">=8.3",
"php-amqplib/php-amqplib": "^3.7",
"utopia-php/di": "0.3.*",
"utopia-php/lock": "0.2.*",
"utopia-php/pools": "1.*",
"utopia-php/servers": "0.4.*",
"utopia-php/telemetry": "0.2.*",
"utopia-php/telemetry": "0.4.*",
"utopia-php/validators": "0.2.*"
},
"require-dev": {
@@ -5036,9 +5037,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/queue/issues",
"source": "https://github.com/utopia-php/queue/tree/0.18.4"
"source": "https://github.com/utopia-php/queue/tree/0.18.6"
},
"time": "2026-05-21T14:43:24+00:00"
"time": "2026-06-01T19:47:57+00:00"
},
{
"name": "utopia-php/registry",
@@ -5192,16 +5193,16 @@
},
{
"name": "utopia-php/storage",
"version": "2.0.3",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "37129cf0bfcc03210172000e4388d4d3495ae013"
"reference": "a604b0ee011c4f366d53167caf2cf6b0f1d62d7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/37129cf0bfcc03210172000e4388d4d3495ae013",
"reference": "37129cf0bfcc03210172000e4388d4d3495ae013",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/a604b0ee011c4f366d53167caf2cf6b0f1d62d7e",
"reference": "a604b0ee011c4f366d53167caf2cf6b0f1d62d7e",
"shasum": ""
},
"require": {
@@ -5211,7 +5212,7 @@
"ext-zlib": "*",
"php": ">=8.1",
"utopia-php/system": "0.*.*",
"utopia-php/telemetry": "0.2.*",
"utopia-php/telemetry": "^0.4",
"utopia-php/validators": "0.2.*"
},
"require-dev": {
@@ -5238,9 +5239,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/2.0.3"
"source": "https://github.com/utopia-php/storage/tree/2.0.4"
},
"time": "2026-05-15T09:42:32+00:00"
"time": "2026-06-02T04:17:22+00:00"
},
{
"name": "utopia-php/system",
@@ -5300,16 +5301,16 @@
},
{
"name": "utopia-php/telemetry",
"version": "0.2.0",
"version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/telemetry.git",
"reference": "9997ebf59bb77920a7223ad73d834a76b09152c3"
"reference": "e0630df7d8176833cd4882f78814a5b893dcb0e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/telemetry/zipball/9997ebf59bb77920a7223ad73d834a76b09152c3",
"reference": "9997ebf59bb77920a7223ad73d834a76b09152c3",
"url": "https://api.github.com/repos/utopia-php/telemetry/zipball/e0630df7d8176833cd4882f78814a5b893dcb0e0",
"reference": "e0630df7d8176833cd4882f78814a5b893dcb0e0",
"shasum": ""
},
"require": {
@@ -5349,9 +5350,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/telemetry/issues",
"source": "https://github.com/utopia-php/telemetry/tree/0.2.0"
"source": "https://github.com/utopia-php/telemetry/tree/0.4.0"
},
"time": "2025-12-17T07:56:38+00:00"
"time": "2026-05-29T11:57:04+00:00"
},
{
"name": "utopia-php/validators",
@@ -8550,7 +8551,9 @@
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {},
"stability-flags": {
"utopia-php/http": 5
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
+21 -21
View File
@@ -112,7 +112,7 @@ services:
condition: service_healthy
coredns:
condition: service_started
ollama:
appwrite-embedding:
condition: service_started
entrypoint:
- php
@@ -304,7 +304,7 @@ services:
depends_on:
- ${_APP_DB_HOST:-mongodb}
- redis
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -346,7 +346,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -380,7 +380,7 @@ services:
- ${_APP_DB_HOST:-mongodb}
- request-catcher-sms
- request-catcher-webhook
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -411,7 +411,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
volumes:
- appwrite-uploads:/storage/uploads:rw
- appwrite-cache:/storage/cache:rw
@@ -481,7 +481,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -524,7 +524,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -657,7 +657,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
volumes:
- appwrite-config:/storage/config:rw
- appwrite-certificates:/storage/certificates:rw
@@ -1075,7 +1075,7 @@ services:
depends_on:
- redis
- ${_APP_DB_HOST:-mongodb}
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -1109,7 +1109,7 @@ services:
depends_on:
- ${_APP_DB_HOST:-mongodb}
- redis
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -1147,7 +1147,7 @@ services:
depends_on:
- ${_APP_DB_HOST:-mongodb}
- redis
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -1185,7 +1185,7 @@ services:
depends_on:
- ${_APP_DB_HOST:-mongodb}
- redis
- ollama
- appwrite-embedding
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
@@ -1358,17 +1358,17 @@ services:
start_period: 10s
command: "postgres"
ollama:
image: appwrite/ollama:0.1.1
container_name: ollama
ports:
- "11434:11434"
restart: unless-stopped
appwrite-embedding:
image: appwrite/embedding:0.1.0
environment:
MODELS: ${_APP_EMBEDDING_MODELS:-embeddinggemma}
OLLAMA_KEEP_ALIVE: 24h
EMBEDDING_MODELS: ${_APP_EMBEDDING_MODELS:-nomic-embed-text}
container_name: appwrite-embedding
ports:
- "3000:3000"
restart: unless-stopped
# persistent for caching models across restarts and preloading
volumes:
- appwrite-models:/root/.ollama
- appwrite-models:/home/embedder/models
networks:
- appwrite
@@ -10,7 +10,7 @@ use Appwrite\SDK\Parameter;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Usage\Context;
use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Agents\Adapters\Ollama;
use Utopia\Agents\Adapters\Appwrite as AppwriteAdapter;
use Utopia\Agents\Agent;
use Utopia\Database\Document;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
@@ -75,7 +75,7 @@ class Create extends CreateDocumentAction
)
])
->param('texts', [], fn (array $plan) => new ArrayList(new Text(0), $plan['databasesMaxEmbeddingTexts'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of text to generate embeddings.', false, ['plan'])
->param('model', Ollama::MODEL_EMBEDDING_GEMMA, new WhiteList(Ollama::MODELS), 'The embedding model to use for generating vector embeddings.', true, enum: new Enum(name: 'EmbeddingModel'))
->param('model', AppwriteAdapter::MODEL_NOMIC_EMBED_TEXT, new WhiteList(AppwriteAdapter::MODELS), 'The embedding model to use for generating vector embeddings.', true, enum: new Enum(name: 'EmbeddingModel'))
->inject('response')
->inject('project')
->inject('embeddingAgent')
@@ -87,50 +87,43 @@ class Create extends CreateDocumentAction
public function action(array $texts, string $model, UtopiaResponse $response, Document $project, Agent $embeddingAgent, Context $usage, Log $log, ?Logger $logger): void
{
$results = [];
$embeddingAgent->getAdapter()->setModel($model);
$dimension = $embeddingAgent->getAdapter()->getEmbeddingDimension();
$adapter = $embeddingAgent->getAdapter();
$adapter->setModel($model);
$dimension = $adapter->getEmbeddingDimension();
$results = [];
$totalDuration = 0;
$totalTokens = 0;
$totalErrors = 0;
foreach ($texts as $text) {
$embedding = [];
$error = '';
foreach (array_chunk($texts, APP_EMBEDDING_BATCH_LIMIT) as $batch) {
try {
$embedResult = $embeddingAgent->embed($text);
$embedding = $embedResult['embedding'];
$embedResult = $embeddingAgent->bulkEmbed($batch);
$totalDuration += $embedResult['totalDuration'] ?? 0;
$totalTokens += $embedResult['tokensProcessed'] ?? 0;
foreach ($embedResult['embeddings'] as $embedding) {
$results[] = $this->embeddingResult($model, $dimension, $embedding);
}
// Partial success: backend returned fewer embeddings than inputs.
// Fill the gap with error results so the response stays 1:1 with texts.
$missing = \count($batch) - \count($embedResult['embeddings']);
for ($i = 0; $i < $missing; $i++) {
$totalErrors++;
$results[] = $this->embeddingResult($model, $dimension, [], 'Error while generating embedding');
}
} catch (\Exception $e) {
$error = 'Error while generating embedding';
$totalErrors += 1;
if ($logger) {
$log->setNamespace("http");
$log->setServer(System::getEnv('_APP_LOGGING_SERVICE_IDENTIFIER', \gethostname()));
$log->setVersion(System::getEnv('_APP_VERSION', 'UNKNOWN'));
$log->setType(Log::TYPE_ERROR);
$log->setMessage($e->getMessage());
$totalErrors += \count($batch);
$this->logError($e, $model, $project, $log, $logger);
$log->addTag('embeddingModel', $model);
$log->addTag('code', $e->getCode());
$log->addTag('projectId', $project->getId());
$log->addExtra('file', $e->getFile());
$log->addExtra('line', $e->getLine());
$log->addExtra('trace', $e->getTraceAsString());
$logger->addLog($log);
// One error result per text in the failed batch.
foreach ($batch as $ignored) {
$results[] = $this->embeddingResult($model, $dimension, [], 'Error while generating embedding');
}
}
$results[] = new Document([
'model' => $model,
'dimension' => $dimension,
'embedding' => $embedding,
'error' => $error
]);
}
$embeddings = new Document([
'embeddings' => $results,
'total' => \count($results),
@@ -150,4 +143,42 @@ class Create extends CreateDocumentAction
->addMetric(METRIC_EMBEDDINGS_TEXT_TOTAL_ERROR, $totalErrors)
->addMetric(\str_replace('{embeddingModel}', $model, METRIC_EMBEDDINGS_MODEL_TEXT_TOTAL_ERROR), $totalErrors);
}
/**
* Build a single embedding response document.
*
* @param float[] $embedding
*/
private function embeddingResult(string $model, int $dimension, array $embedding, string $error = ''): Document
{
return new Document([
'model' => $model,
'dimension' => $dimension,
'embedding' => $embedding,
'error' => $error,
]);
}
private function logError(\Throwable $e, string $model, Document $project, Log $log, ?Logger $logger): void
{
if ($logger === null) {
return;
}
$log->setNamespace('http');
$log->setServer(System::getEnv('_APP_LOGGING_SERVICE_IDENTIFIER', \gethostname()));
$log->setVersion(System::getEnv('_APP_VERSION', 'UNKNOWN'));
$log->setType(Log::TYPE_ERROR);
$log->setMessage($e->getMessage());
$log->addTag('embeddingModel', $model);
$log->addTag('code', $e->getCode());
$log->addTag('projectId', $project->getId());
$log->addExtra('file', $e->getFile());
$log->addExtra('line', $e->getLine());
$log->addExtra('trace', $e->getTraceAsString());
$logger->addLog($log);
}
}
@@ -5,7 +5,6 @@ namespace Appwrite\Platform\Modules\Databases\Workers;
use Appwrite\Event\Message\Database as DatabaseMessage;
use Appwrite\Event\Realtime;
use Exception;
use Utopia\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Exception as DatabaseException;
@@ -18,6 +17,7 @@ use Utopia\Database\Query;
use Utopia\Logger\Log;
use Utopia\Platform\Action;
use Utopia\Queue\Message;
use Utopia\Span\Span;
class Databases extends Action
{
@@ -62,10 +62,21 @@ class Databases extends Action
}
$databaseMessage = DatabaseMessage::fromArray($payload);
$type = $databaseMessage->type;
Span::add('payload.type', $type);
$document = $databaseMessage->row ?? $databaseMessage->document ?? new Document();
Span::add('database.document.id', $document->getId());
$collection = $databaseMessage->table ?? $databaseMessage->collection ?? new Document();
Span::add('database.collection.id', $collection->getId());
$database = $databaseMessage->database ?? new Document();
Span::add('database.id', $database->getId());
Span::add('database.namespace', $dbForProject->getNamespace());
Span::add('database.tenant', $dbForProject->getTenant());
/**
* @var Database $dbForDatabases
*/
@@ -88,14 +99,6 @@ class Databases extends Action
DATABASE_TYPE_DELETE_INDEX => $this->deleteIndex($database, $collection, $document, $project, $dbForPlatform, $dbForProject, $dbForDatabases, $queueForRealtime),
default => throw new Exception('No database operation for type: ' . \strval($type)),
};
Console::info("Finished processing database operation: \n" . \json_encode([
'type' => $type,
'projectId' => $project->getId(),
'databaseId' => $database->getId(),
'collectionId' => $collection->getId(),
'documentId' => $document->getId(),
], JSON_PRETTY_PRINT));
}
/**
@@ -206,8 +209,6 @@ class Databases extends Action
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'available'));
} catch (\Throwable $e) {
Console::error($e->getMessage());
if ($e instanceof DatabaseException) {
$attribute->setAttribute('error', $e->getMessage());
if (! $relatedAttribute->isEmpty()) {
@@ -309,7 +310,7 @@ class Databases extends Action
}
} catch (NotFound $e) {
Console::error($e->getMessage());
Span::add('database.attribute.not_found', $e->getMessage());
$dbForProject->deleteDocument('attributes', $attribute->getId());
@@ -318,8 +319,6 @@ class Databases extends Action
}
} catch (\Throwable $e) {
Console::error($e->getMessage());
if ($e instanceof DatabaseException) {
$attribute->setAttribute('error', $e->getMessage());
if (!$relatedAttribute->isEmpty()) {
@@ -456,7 +455,6 @@ class Databases extends Action
}
$dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'available'));
} catch (\Throwable $e) {
Console::error($e->getMessage());
if ($e instanceof DatabaseException) {
$index->setAttribute('error', $e->getMessage());
}
@@ -512,8 +510,6 @@ class Databases extends Action
$dbForProject->deleteDocument('indexes', $index->getId());
$index->setAttribute('status', 'deleted');
} catch (\Throwable $e) {
Console::error($e->getMessage());
if ($e instanceof DatabaseException) {
$index->setAttribute('error', $e->getMessage());
}
@@ -613,7 +609,7 @@ class Databases extends Action
*/
protected function deleteByGroup(string $collectionId, array $queries, Database $database, ?callable $callback = null): void
{
$start = \microtime(true);
Span::add('delete_by_group.collection.id', $collectionId);
try {
$count = $database->deleteDocuments(
@@ -623,13 +619,11 @@ class Databases extends Action
$callback
);
} catch (\Throwable $th) {
$tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : '';
Console::error("Failed to delete documents/rows for collection/table: {$database->getNamespace()}_{$collectionId} {$tenant} :{$th->getMessage()}");
Span::add('delete_by_group.error', $th->getMessage());
return;
}
$end = \microtime(true);
Console::info("Deleted {$count} documents/rows by group in " . ($end - $start) . " seconds");
Span::add('delete_by_group.count', $count);
}
/**
@@ -297,13 +297,9 @@ class Builds extends Action
$templateReferenceValue = $template->getAttribute('referenceValue', '');
$templateRootDirectory = $template->getAttribute('rootDirectory', '');
$templateRootDirectory = \trim($templateRootDirectory, '/');
while (\str_starts_with($templateRootDirectory, './')) {
$templateRootDirectory = \substr($templateRootDirectory, 2);
}
if ($templateRootDirectory !== '' && \preg_match('#(^|/)\.\.(/|$)#', $templateRootDirectory)) {
throw new \Exception('Invalid template root directory');
}
$templateRootDirectory = \rtrim($templateRootDirectory, '/');
$templateRootDirectory = \ltrim($templateRootDirectory, '.');
$templateRootDirectory = \ltrim($templateRootDirectory, '/');
if (! empty($templateRepositoryName) && ! empty($templateOwnerName) && ! empty($templateReferenceType) && ! empty($templateReferenceValue)) {
$stdout = '';
@@ -366,10 +362,9 @@ class Builds extends Action
// VCS and VCS+Temaplte
$tmpDirectory = '/tmp/builds/' . $deploymentId . '/code';
$rootDirectory = $resource->getAttribute('providerRootDirectory', '');
$rootDirectory = \trim($rootDirectory, '/');
if ($rootDirectory !== '' && \preg_match('#(^|/)\.\.(/|$)#', $rootDirectory)) {
throw new \Exception('Invalid root directory');
}
$rootDirectory = \rtrim($rootDirectory, '/');
$rootDirectory = \ltrim($rootDirectory, '.');
$rootDirectory = \ltrim($rootDirectory, '/');
$owner = $github->getOwnerName($providerInstallationId);
$repositoryName = $github->getRepositoryName($providerRepositoryId);
@@ -425,13 +420,9 @@ class Builds extends Action
$templateReferenceValue = $template->getAttribute('referenceValue', '');
$templateRootDirectory = $template->getAttribute('rootDirectory', '');
$templateRootDirectory = \trim($templateRootDirectory, '/');
while (\str_starts_with($templateRootDirectory, './')) {
$templateRootDirectory = \substr($templateRootDirectory, 2);
}
if ($templateRootDirectory !== '' && \preg_match('#(^|/)\.\.(/|$)#', $templateRootDirectory)) {
throw new \Exception('Invalid template root directory');
}
$templateRootDirectory = \rtrim($templateRootDirectory, '/');
$templateRootDirectory = \ltrim($templateRootDirectory, '.');
$templateRootDirectory = \ltrim($templateRootDirectory, '/');
if (! empty($templateRepositoryName) && ! empty($templateOwnerName) && ! empty($templateReferenceType) && ! empty($templateReferenceValue)) {
// Clone template repo
@@ -497,6 +497,8 @@ class Create extends Action
->setParam('bucketId', $bucket->getId())
->setParam('fileId', $file->getId())
->setContext('bucket', $bucket);
} else {
$queueForEvents->reset();
}
$metadata = null; // was causing leaks as it was passed by reference
@@ -22,7 +22,7 @@ class Embedding extends Model
->addRule('model', [
'type' => self::TYPE_STRING,
'description' => 'Embedding model used to generate embeddings.',
'example' => 'embeddinggemma'
'example' => 'nomic-embed-text'
])
->addRule('dimension', [
'type' => self::TYPE_INTEGER,
+2 -2
View File
@@ -2035,7 +2035,7 @@ class UsageTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey'],
], $this->getHeaders()),
[
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => ['usage test warm-up ' . $callCount],
]
);
@@ -2059,7 +2059,7 @@ class UsageTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey'],
], $this->getHeaders()),
[
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => ['usage test text ' . $i],
]
);
@@ -582,7 +582,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => [
'hello world',
'second sentence',
@@ -616,7 +616,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => [
'valid text',
123, // invalid, not a string
@@ -581,7 +581,7 @@ class VectorsDBCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => [
'hello world',
'second sentence',
@@ -615,7 +615,7 @@ class VectorsDBCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'model' => 'embeddinggemma',
'model' => 'nomic-embed-text',
'texts' => [
'valid text',
123, // invalid, not a string