fix: don't crash on 404, add sync debug logging

ProjectKey.fetch_key now returns empty defaults instead of raising
RuntimeError on API errors. Added logging to _syncFromSource and
fetch_key to trace the seq=4001 vs seq=4 mismatch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 20:58:42 +01:00
parent 413e1c09e9
commit ff5802ab63
2 changed files with 18 additions and 3 deletions
+10 -1
View File
@@ -264,10 +264,19 @@ class ProjectKey:
file_name="", sequence_number=1): file_name="", sequence_number=1):
# source_label is used by JS to identify which ProjectSource to sync # source_label is used by JS to identify which ProjectSource to sync
# config from. The actual config arrives via the optional widgets below. # config from. The actual config arrives via the optional widgets below.
logger.info("ProjectKey.fetch_key: source=%s key=%s url=%s project=%s file=%s seq=%s",
source_label, key_name, manager_url, project_name, file_name, sequence_number)
data = _fetch_data(manager_url, project_name, file_name, sequence_number) data = _fetch_data(manager_url, project_name, file_name, sequence_number)
if data.get("error") in ("http_error", "network_error", "parse_error"): if data.get("error") in ("http_error", "network_error", "parse_error"):
msg = data.get("message", "Unknown error") msg = data.get("message", "Unknown error")
raise RuntimeError(f"Failed to fetch data: {msg}") logger.warning("ProjectKey.fetch_key failed: %s", msg)
# Return empty/default instead of crashing the workflow
if key_type == "INT":
return (0,)
elif key_type == "FLOAT":
return (0.0,)
else:
return ("",)
val = data.get(key_name, "") val = data.get(key_name, "")
+8 -2
View File
@@ -121,11 +121,17 @@ app.registerExtension({
nodeType.prototype._syncFromSource = function () { nodeType.prototype._syncFromSource = function () {
const srcWidget = this.widgets?.find(w => w.name === "source_label"); const srcWidget = this.widgets?.find(w => w.name === "source_label");
const source = this._findSource(srcWidget?.value); const source = this._findSource(srcWidget?.value);
if (!source) return; if (!source) {
console.log(`[ProjectKey] _syncFromSource id=${this.id}: no source found for label="${srcWidget?.value}"`);
return;
}
for (const name of ["manager_url", "project_name", "file_name", "sequence_number"]) { for (const name of ["manager_url", "project_name", "file_name", "sequence_number"]) {
const dst = this.widgets?.find(w => w.name === name); const dst = this.widgets?.find(w => w.name === name);
const src = source.widgets?.find(w => w.name === name); const src = source.widgets?.find(w => w.name === name);
if (dst && src) dst.value = src.value; if (dst && src) {
dst.value = src.value;
console.log(`[ProjectKey] _syncFromSource id=${this.id}: ${name}="${src.value}"`);
}
} }
}; };