nixos-module: work around upstream language-list caching bug

Migration 2025_08_31_224356_additional_languages_af_ca_id.php runs
during `migrate`, before db:seed's LanguageSeeder has populated the
other 42 rows of the languages table, and does
Cache::forever('languages', Language::all()) - permanently caching
just the 3 languages (Afrikaans, Catalan, Indonesian) it sees at that
moment. StaticServiceProvider checks this cache key before ever
querying the DB again, so every fresh install's language dropdown
(e.g. the "Welcome to Invoice Ninja" company setup wizard) was stuck
showing only those 3 entries, in their own native-language spelling
(ctrans() translates each name using the active locale).

Adds an unconditional `invoiceninja-manage cache:forget languages` to
invoiceninja-data-setup.service, and a regression test asserting
/api/v1/statics returns more than 40 languages. Verified directly:
before the fix, a fresh account's statics call returned exactly 3
languages; after, it returns all 45.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-26 15:17:22 -04:00
co-authored by Claude Sonnet 5
parent d7fea37e25
commit 7d7d717745
3 changed files with 30 additions and 1 deletions
+15
View File
@@ -21,6 +21,8 @@ pkgs.testers.nixosTest {
};
testScript = ''
import json
def check_invoiceninja(machine, proxy_unit):
machine.wait_for_unit("mysql.service")
machine.wait_for_unit("redis-invoiceninja.service")
@@ -65,6 +67,19 @@ pkgs.testers.nixosTest {
)
assert "${adminEmail}" in login_response, f"login did not succeed: {login_response}"
with subtest("full language list is available, not just the af/ca/id migration's 3"):
# Regression check: migration 2025_08_31_224356_additional_languages_af_ca_id.php runs
# during `migrate`, before db:seed's LanguageSeeder has populated the other 42 rows, and
# does Cache::forever('languages', Language::all()) - permanently caching just the 3
# languages it sees at that moment. invoiceninja-data-setup works around this with
# `invoiceninja-manage cache:forget languages`; this confirms the workaround is in place.
token = json.loads(login_response)["data"][0]["token"]["token"]
statics = machine.succeed(
f"curl -sf http://localhost/api/v1/statics -H 'X-API-TOKEN: {token}'"
)
language_count = len(json.loads(statics)["languages"])
assert language_count > 40, f"expected ~45 languages, got {language_count}"
nginx.start()
caddy.start()