Skip to content

Commit c3cb07f

Browse files
i2h3claude
andcommitted
fix(loopback): set test_dummy_token before first HTTP request
The `circles:check` loopback test always fails with a 401 on the POST request to `asyncBroadcast` with `test-dummy-token` when the config key `test_dummy_token` does not already exist in the database. Root cause: The GET request to `core.CSRFToken.index` (which runs first) causes the web server process to load all `appconfig` values into its APCu local cache (TTL=3s). Only then does the CLI process insert `test_dummy_token` into the database and clear its own APCu cache — but CLI and web server run in separate SAPI contexts with independent APCu stores, so the web cache is unaffected. When the POST request arrives shortly after the GET (well within the 3-second TTL), the web process reads from its still-valid APCu cache, which does not contain the newly inserted key. `getValueInt()` therefore returns the default `0`, and `0 < time()` evaluates to true, causing the controller to return 401. Moving `setValueInt()` before the GET request ensures the key exists in the database before any web request loads the appconfig into APCu. Signed-Off-By: Iva Horn <iva.horn@nextcloud.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3faa4cd commit c3cb07f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Command/CirclesCheck.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,12 @@ private function setupLoopback(InputInterface $input, OutputInterface $output, s
256256
* @throws UnknownRemoteException
257257
*/
258258
private function testLoopback(InputInterface $input, OutputInterface $output): bool {
259+
$this->appConfig->setValueInt(Application::APP_ID, 'test_dummy_token', time() + 10);
260+
259261
if (!$this->testRequest($output, 'GET', 'core.CSRFToken.index')) {
260262
return false;
261263
}
262264

263-
$this->appConfig->setValueInt(Application::APP_ID, 'test_dummy_token', time() + 10);
264265
if (!$this->testRequest(
265266
$output, 'POST', 'circles.EventWrapper.asyncBroadcast',
266267
['token' => 'test-dummy-token']

0 commit comments

Comments
 (0)