From fe47059f880064c195d6f89bcae07a7b444439b6 Mon Sep 17 00:00:00 2001 From: x01dc Date: Mon, 27 Jul 2026 16:58:43 +0200 Subject: [PATCH] fix(OMNY): skip PDF upload without a real tomo_id, widen error logging tomo_id == FALLBACK_TOMO_ID (0) means add_sample_database() never actually registered a measurement server-side, so there's no reserved "new.pdf" slot -- uploading anyway would silently claim whatever number countersaver.txt currently holds, i.e. an unrelated real measurement's slot. Skip with a clear message instead. Also widen the truncated response text in the upload warning/log messages (120 -> 400 chars), which had cut off the file+line a real PHP error would show, making a live parse-error response undiagnosable from the client log alone (as happened while testing this). --- .../plugins/OMNY_shared/tomo_queue_mixin.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/tomo_queue_mixin.py b/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/tomo_queue_mixin.py index f91f71a..e3b7cb1 100644 --- a/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/tomo_queue_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/OMNY_shared/tomo_queue_mixin.py @@ -421,6 +421,20 @@ class TomoQueueMixin: """ def _run(): + # tomo_id_manager.FALLBACK_TOMO_ID (0) means add_sample_database() + # never actually registered anything server-side (no valid + # e-account) -- there's no real "new.pdf" slot reserved for this + # session, so uploading would just claim whatever number + # countersaver.txt currently happens to hold, i.e. some unrelated + # real measurement's slot. Skip rather than risk clobbering it. + if self.tomo_id == self.tomo_id_manager.FALLBACK_TOMO_ID: + print( + f"Skipping PDF upload: tomo_id={self.tomo_id} means no real " + "measurement was registered (not a valid e-account) -- " + "there's no samples-folder slot to upload into." + ) + return + try: import base64 @@ -451,13 +465,13 @@ class TomoQueueMixin: allow_redirects=False, # SSRF hardening ) if r.status_code != 200: - print(f"PDF upload to {url} -> HTTP {r.status_code}: {r.text[:120]}") + print(f"PDF upload to {url} -> HTTP {r.status_code}: {r.text[:400]}") continue if expected_name not in r.text: print( f"PDF upload to {url} succeeded but the server-assigned " f"filename doesn't match tomo_id {self.tomo_id} (response: " - f"{r.text[:120]!r}) -- a concurrent measurement " + f"{r.text[:400]!r}) -- a concurrent measurement " "registration may have raced this upload." ) else: