Skip to content

Commit e3107d1

Browse files
i2h3claude
authored andcommitted
fix(loopback): allow wrapper creation for loopback tests from CLI
Even after the 401 is resolved, `circles:check` still fails with "Event created too many Wrappers" (actually zero wrappers found, the message is misleading). The LoopbackTest FederatedEvent never gets an EventWrapper created when running from CLI. Root cause: `initBroadcast()` has an early-return guard: if (empty($instances) && (!$event->isAsync() || OC::$CLI)) For a LoopbackTest event (which implements IFederatedItemAsyncProcess but has no remote instances), `$instances` is empty. Combined with `OC::$CLI === true`, the guard returns false — skipping all wrapper creation. This optimisation is correct for regular async events in CLI mode, where `newEvent()` already calls `manage()` synchronously and no async broadcast is needed. However, the LoopbackTest specifically exists to verify that the async loopback path works end-to-end: wrapper creation, async POST, `manageWrapper()`, and `confirmStatus()` must all run to produce the verify/manage values that `testLoopback()` asserts. The fix exempts events whose class implements IFederatedItemLoopbackTest from the CLI guard, so that a wrapper is created and the async broadcast is triggered even when running from CLI. The double call to `manage()` (once synchronously in `newEvent()`, once asynchronously via the wrapper) is harmless for LoopbackTest since it only sets an idempotent result value. Signed-Off-By: Iva Horn <iva.horn@nextcloud.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a6009f9 commit e3107d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Service/FederatedEventService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ private function configureEvent(FederatedEvent $event, IFederatedItem $item) {
344344
public function initBroadcast(FederatedEvent $event): bool {
345345
$instances = $this->getInstances($event);
346346
// if empty instance and ran from CLI, any action as already been managed
347-
if (empty($instances) && (!$event->isAsync() || OC::$CLI)) {
347+
// except for loopback tests which need async verification even from CLI
348+
$isLoopbackTest = is_a($event->getClass(), IFederatedItemLoopbackTest::class, true);
349+
if (empty($instances) && (!$event->isAsync() || (OC::$CLI && !$isLoopbackTest))) {
348350
return false;
349351
}
350352

0 commit comments

Comments
 (0)