fix(web-app-nextcloud): write onlyoffice's server URL last and recheck it

The role writes onlyoffice's settings with one occ call per key,
DocumentServerUrl first and jwt_secret fourth. Nextcloud loads app
config once per process, so a cron.php that starts inside that batch
runs onlyoffice's EditorsCheck job, registered when the app was
enabled, with the document server URL but without the secret. The
document server answers "Invalid token", EditorsCheck stores it in
settings_error, and onlyoffice stops loading its Files integration;
EditorsCheck itself skips every later run while that error is set.

Seen in run 38455782184 (Nextcloud#4, swarm): cron.php started at
06:50:00 inside the batch that ran from 06:49:59 to 06:50:04, logged
"Invalid token" at 06:50:22, and both Playwright passes found .docx
files offered for download only.

DocumentServerUrl is now written last, so a process that cached the
config before the batch ended sees no URL and EditorsCheck returns
early. After the batch, `occ onlyoffice:documentserver --check` sets
settings_error from a fresh check: a redeploy clears an error latched
earlier, and a document server that stays unreachable fails the
deploy. A unit test keeps the URL last.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-14 13:34:52 +02:00
1 parent 67b508cc5d
commit bfaa834f29
3 files changed
+35 -3

No files matched your search

@@ -0,0 +1,24 @@
from __future__ import annotations
import unittest
from utils.cache.files import PROJECT_ROOT, read_text
from utils.cache.yaml import load_yaml_str
ADDON = PROJECT_ROOT / "roles/web-app-nextcloud/meta/addons/onlyoffice.yml"
class TestOnlyofficeConfigurationOrder(unittest.TestCase):
def test_the_document_server_url_is_written_last(self) -> None:
config = load_yaml_str(read_text(str(ADDON)))["config"]["plugin_configuration"]
self.assertEqual(
config[-1]["configkey"],
"DocumentServerUrl",
"a cron.php that caches app config before the last write must see no "
"DocumentServerUrl, or onlyoffice's EditorsCheck runs without jwt_secret "
"and latches settings_error",
)
if __name__ == "__main__":
unittest.main()