chore: upgrade utopia queue and replace App with Http#11239
chore: upgrade utopia queue and replace App with Http#11239ChiragAgg5k merged 10 commits into1.8.xfrom
Conversation
📝 WalkthroughWalkthroughcomposer.json updates Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
✨ Benchmark results
⚡ Benchmark Comparison
|
4d805b3 to
5291138
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
src/Appwrite/GraphQL/Schema.php (1)
5-10:⚠️ Potential issue | 🔴 CriticalRe-add
Utopia\Appimport for existing type hints.
Appis used in the method signature (line 29) but the import is missing. Without it, the type hint resolves to\Appwrite\GraphQL\Appwhich does not exist and will cause a fatal error.Proposed fix
use GraphQL\Type\Schema as GQLSchema; +use Utopia\App; use Utopia\Http;src/Appwrite/GraphQL/Resolvers.php (1)
5-10:⚠️ Potential issue | 🔴 CriticalMissing
Utopia\Appimport or incomplete refactoring toUtopia\Http.The file uses
Apptype hints throughout (lines 19, 24, 29, 64, 71, 86, 93, etc.) but imports onlyUtopia\Httpwithout importingUtopia\App. Without the import,Appcannot resolve in theAppwrite\GraphQLnamespace and will cause fatal errors. Either adduse Utopia\App;or complete the refactoring by changing all type hints fromApptoHttp.app/controllers/shared/api/auth.php (1)
33-41:⚠️ Potential issue | 🔴 CriticalType hint mismatch -
Appis no longer imported.Line 40 uses
App $utopiatype hint in the closure, butUtopia\Appwas replaced withUtopia\Httpon line 7. This will cause a fatal error at runtime sinceAppis undefined.🐛 Proposed fix
- ->action(function (App $utopia, Request $request, Document $project, Reader $geodb, Authorization $authorization) { + ->action(function (Http $utopia, Request $request, Document $project, Reader $geodb, Authorization $authorization) {src/Appwrite/Platform/Tasks/Specs.php (1)
334-336:⚠️ Potential issue | 🔴 CriticalUndefined class
Appat line 335 - will cause fatal error at runtime.Line 335 uses
new App('UTC')butUtopia\Appis not imported. The file importsUtopia\Httpinstead (line 15), which suggests an incomplete migration fromApptoHttp. SinceUtopia\Httphas the same constructor signature and accepts the timezone parameter, changenew App('UTC')tonew Http('UTC')on line 335. This same issue exists insrc/Appwrite/Platform/Tasks/Migrate.php:88andsrc/Appwrite/SDK/Specification/Format.phpalso declares the undefinedApptype hint.app/controllers/mock.php (1)
283-289:⚠️ Potential issue | 🔴 CriticalFix shutdown hook type-hint for
utopiaresource in 3 files.
Appis not imported in any of these files, so the type-hint will cause a fatal error at runtime. The injectedutopiaresource is an instance ofUtopia\Http, which provides bothgetRoute()andmatch(Request $request)methods. Change the type-hint toHttpto match the injected resource.Affected files and lines:
app/controllers/mock.phpline 288app/controllers/shared/api.php(multiple shutdown hooks)app/controllers/shared/api/auth.php🔧 Example fix (from mock.php)
- ->action(function (App $utopia, Response $response, Request $request) { + ->action(function (Http $utopia, Response $response, Request $request) {
🤖 Fix all issues with AI agents
In `@app/realtime.php`:
- Line 19: Add the missing import for the App class so PHP resolves new
App('UTC') correctly at runtime: insert a `use Utopia\App;` alongside the other
use statements near the top of the file so the `new App('UTC')` instantiation
(symbol: App) references the correct Utopia\App class instead of the global
namespace.
In `@src/Appwrite/SDK/Specification/Format.php`:
- Around line 5-7: The file is missing an import for the App class used in the
Format class type hint and the constructor parameter; add the appropriate import
(e.g., use Appwrite\App;) at the top of the file so the Format class's type hint
and the __construct(App $app, ...) parameter resolve correctly instead of
assuming Appwrite\SDK\Specification\App.
db807a3 to
4f935ee
Compare
4f935ee to
1eaf5d5
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
app/controllers/api/vcs.php (1)
1767-1853:⚠️ Potential issue | 🔴 CriticalAdd missing Request dependency injection.
The action function requires
Request $requestparameter (used on the final line), but->inject('request')is missing from the route's dependency chain. Utopia Http does not auto-injectRequestby type-hint alone; explicit injection is required.🛠️ Suggested fix
Http::patch('/v1/vcs/github/installations/:installationId/repositories/:repositoryId') ->desc('Update external deployment (authorize)') ->groups(['api', 'vcs']) ->label('scope', 'vcs.write') @@ ->inject('gitHub') + ->inject('request') ->inject('response')app/controllers/api/messaging.php (3)
481-487:⚠️ Potential issue | 🟠 MajorMsg91 providers can never be enabled at creation.
$options['from']is never set and there’s nofromparam, so$enabledis always forced to false even with valid credentials.Suggested fix
if ( $enabled === true && \array_key_exists('senderId', $credentials) && \array_key_exists('authKey', $credentials) - && \array_key_exists('from', $options) + && \array_key_exists('templateId', $credentials) ) {
2329-2335:⚠️ Potential issue | 🟠 MajorAPNS update stores
bundleIdunder the wrong key.You write
bundlebut the enablement check expectsbundleId, which can prevent enabling after an update.Suggested fix
- $credentials['bundle'] = $bundleId; + $credentials['bundleId'] = $bundleId;
2513-2521:⚠️ Potential issue | 🟠 MajorCursor should use the document, not
$cursorDocument[0].
getDocument()returns aDocument; indexing it is likely null/invalid and can break cursor pagination.Suggested fix
- $cursor->setValue($cursorDocument[0]); + $cursor->setValue($cursorDocument);
🧹 Nitpick comments (5)
app/controllers/api/migrations.php (1)
453-457: Remove duplicatesetProject()in CSV import trigger.
setProject()is invoked twice in a row; likely a copy/paste artifact. If you intended to pass other context (e.g., platform/user), replace the duplicate with the missing call.Suggested tweak
$queueForMigrations ->setMigration($migration) ->setProject($project) - ->setProject($project) ->trigger();app/http.php (1)
184-184:$poolsparameter is unused increateDatabase.PHPMD already flagged this; consider removing the parameter and adjusting call sites.
Suggested change (update call sites accordingly)
-function createDatabase(Http $app, string $resourceKey, string $dbName, array $collections, mixed $pools, callable $extraSetup = null): void +function createDatabase(Http $app, string $resourceKey, string $dbName, array $collections, callable $extraSetup = null): voidapp/controllers/general.php (1)
63-63: Remove unused$utopiaparameter fromrouter()and call sites.PHPMD flags this as an unused parameter. Dropping it reduces noise without changing behavior.
♻️ Proposed update
-function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, array $platform, string $previewHostname, Authorization $authorization, ?Key $apiKey, DeleteEvent $queueForDeletes, int $executionsRetentionCount) +function router(Database $dbForPlatform, callable $getProjectDB, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, array $platform, string $previewHostname, Authorization $authorization, ?Key $apiKey, DeleteEvent $queueForDeletes, int $executionsRetentionCount) { ... }- if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { + if (router($dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { $utopia->getRoute()?->label('router', true); }- if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { + if (router($dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { $utopia->getRoute()?->label('router', true); }- if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { + if (router($dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { $utopia->getRoute()?->label('router', true); }- if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { + if (router($dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $platform, $previewHostname, $authorization, $apiKey, $queueForDeletes, $executionsRetentionCount)) { $utopia->getRoute()?->label('router', true); }Also applies to: 898-902, 1189-1193, 1582-1584, 1617-1619
app/init/resources.php (2)
1207-1209: Suspicious unused parameter in plan resource callback.The
$planparameter in the callback signature has a default value and is never used - the function always returns an empty array. This parameter appears to be dead code. If$planis meant to be injected from another resource, it should be listed in the dependencies array (the third parameter tosetResource).-Http::setResource('plan', function (array $plan = []) { +Http::setResource('plan', function () { return []; });
86-87: Global variable pattern for register initialization is systematic and intentional.The
global $register;usage is part of an established bootstrap pattern used consistently across all entry points (app/init/resources.php,app/cli.php,app/worker.php, etc.) where the globally-initialized registry is immediately exposed through each system's resource container. While the global keyword creates a temporary dependency during bootstrap, the register is properly registered as a resource rather than left as an implicit dependency throughout the application.If future refactoring removes the global bootstrap pattern entirely in favor of pure dependency injection at the initialization layer, this global usage would be eliminated naturally.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/controllers/api/vcs.php (1)
597-611:⚠️ Potential issue | 🟡 MinorFix undefined
$redirectFailurein the project-not-found branch.
It’s checked before assignment, which can trigger notices and skip a valid redirect.🛠️ Suggested fix
- $state = \json_decode($state, true); + $state = \json_decode($state, true); + $redirectFailure = \is_array($state) ? ($state['failure'] ?? '') : ''; $projectId = $state['projectId'] ?? '';
🧹 Nitpick comments (1)
app/controllers/general.php (1)
63-63: Remove or use unused$utopiaparameter inrouter.
Line 63:$utopiaisn’t referenced in the function body, which matches the static analysis warning. If not required, drop it and update call sites.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@composer.json`:
- Around line 75-77: Update composer.json to ensure your environment and
dependency constraints match the new package requirements: verify and bump the
PHP engine requirement to ">=8.1" if you intend to upgrade to utopia-php/swoole
1.0.*, and restrict or pin "utopia-php/swoole" and "utopia-php/telemetry" to
compatible versions if you cannot meet Swoole 6.x or the newer telemetry
dependency versions; specifically check and adjust the "require" entries for
utopia-php/swoole and utopia-php/telemetry and the "platform" PHP version
(engine) constraint, and run composer why-not / composer update to confirm no
other packages conflict with PHP 8.1 or Swoole 6 before merging.
- Line 72: Pin the dependency to a commit SHA to ensure reproducible builds:
replace the current version string "utopia-php/queue": "dev-fix-servers-lib as
0.15.3" in composer.json with a commit-pinned reference using the branch plus
SHA, e.g. "utopia-php/queue": "dev-fix-servers-lib#<COMMIT_SHA> as 0.15.3",
where <COMMIT_SHA> is the exact commit you want to lock to.
No description provided.