From ba81f2f8bb518ff06c39562460386c3e59022f82 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 14 Oct 2026 14:21:18 +0200 Subject: [PATCH] :bug: Fix audit-log-archive cron submit and nitrate wiring (#12321) After the unified jobs migration, cron submitted empty params that failed validation because the job schema still required Integrant system keys. Narrow the schema to optional REPL overrides, wire :app.nitrate/client onto the archive job-def, and drop the unused ::jobs/defs ref from nitrate that created an Integrant cycle. AI-assisted-by: composer --- backend/src/app/loggers/audit/archive_task.clj | 8 +++----- backend/src/app/main.clj | 10 ++++++---- .../backend_tests/loggers_audit_archive_task_test.clj | 11 +++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/backend/src/app/loggers/audit/archive_task.clj b/backend/src/app/loggers/audit/archive_task.clj index 1264882eaa..6c29c29d6b 100644 --- a/backend/src/app/loggers/audit/archive_task.clj +++ b/backend/src/app/loggers/audit/archive_task.clj @@ -256,12 +256,10 @@ (declare execute-audit-log-archive) (def schema:audit-log-archive-params - "Optional overrides for the repl invocation defaults." + "Optional overrides for the repl invocation defaults. + Cron submits {}; system deps (pool, shared-keys, http) live on the + job-def cfg closed over by the handler, not in job params." [:map - ::db/pool - ::setup/shared-keys - ::http/client - [:app.nitrate/client {:optional true} [:maybe :map]] [:enabled {:optional true} :boolean] [:uri {:optional true} ::sm/uri]]) diff --git a/backend/src/app/main.clj b/backend/src/app/main.clj index d5aa7538c0..2c34fc8c94 100644 --- a/backend/src/app/main.clj +++ b/backend/src/app/main.clj @@ -543,7 +543,8 @@ :app.nitrate/client {::http.client/client (ig/ref ::http.client/client) - ::jobs/defs (ig/ref ::jobs/defs) + ;; No ::jobs/defs: nitrate never submits jobs, and archive-task's + ;; job-def needs this client — that would cycle through jobs/defs. ::setup/shared-keys (ig/ref ::setup/shared-keys)} :app.rpc/management-methods @@ -679,10 +680,11 @@ ::mtx/metrics (ig/ref ::mtx/metrics)} :app.loggers.audit.archive-task/job-def - {::db/pool (ig/ref ::db/pool) + {::db/pool (ig/ref ::db/pool) ::http.client/client (ig/ref ::http.client/client) - ::setup/shared-keys (ig/ref ::setup/shared-keys) - ::mtx/metrics (ig/ref ::mtx/metrics)} + ::setup/shared-keys (ig/ref ::setup/shared-keys) + :app.nitrate/client (ig/ref :app.nitrate/client) + ::mtx/metrics (ig/ref ::mtx/metrics)} :app.loggers.audit.gc-task/job-def {::db/pool (ig/ref ::db/pool) diff --git a/backend/test/backend_tests/loggers_audit_archive_task_test.clj b/backend/test/backend_tests/loggers_audit_archive_task_test.clj index 863885a085..a04c2c2fd1 100644 --- a/backend/test/backend_tests/loggers_audit_archive_task_test.clj +++ b/backend/test/backend_tests/loggers_audit_archive_task_test.clj @@ -7,12 +7,15 @@ (ns backend-tests.loggers-audit-archive-task-test (:require [app.common.json :as json] + [app.common.schema :as sm] [app.common.time :as ct] + [app.common.uri :as u] [app.common.uuid :as uuid] [app.config :as cf] [app.db :as db] [app.http.client :as-alias http] [app.jobs :as jobs] + [app.loggers.audit.archive-task :as archive] [app.setup :as-alias setup] [backend-tests.helpers :as th] [clojure.test :as t] @@ -348,3 +351,11 @@ (t/is (= (:name team) (:team-name props)))) (let [rows (th/db-exec! ["select * from audit_log where archived_at is not null"])] (t/is (= 2 (count rows)))))))) + +(t/deftest archive-params-accept-empty-cron-props + ;; Cron always submits (or props {}) — system deps live on the + ;; job-def cfg, not in params. Requiring them here blocks every tick. + (let [valid? (sm/validator archive/schema:audit-log-archive-params)] + (t/is (true? (valid? {}))) + (t/is (true? (valid? {:enabled true}))) + (t/is (true? (valid? {:uri (u/uri archive-uri)})))))