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).
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user