v1.0.77: debug logging in api_params to trace modify flow
This commit is contained in:
+14
-1
@@ -102,33 +102,42 @@ def api_params(op_id):
|
||||
try:
|
||||
instance_uid = request.args.get("instanceUid")
|
||||
op_name = request.args.get("opName")
|
||||
print(f"[api_params] op_id={op_id} instanceUid={instance_uid!r} opName={op_name!r}", flush=True)
|
||||
|
||||
if instance_uid and op_name:
|
||||
print(f"[api_params] PREVIEW branch: creating operation for instance={instance_uid}", flush=True)
|
||||
# Создать pending-операцию чтобы прочитать ТЕКУЩИЕ значения параметров инстанса
|
||||
op_payload = {"instanceUid": instance_uid, "svcOperationId": op_id, "operation": op_name}
|
||||
op_resp = _client().post("/instanceOperations", op_payload)
|
||||
preview_op_uid = _find_uid(op_resp) or _uid_from_location(op_resp.get("_location", ""))
|
||||
print(f"[api_params] preview_op_uid={preview_op_uid!r}", flush=True)
|
||||
if not preview_op_uid:
|
||||
return jsonify({"error": "Не удалось создать preview-операцию"}), 500
|
||||
|
||||
op_data = _client().get(f"/instanceOperations/{preview_op_uid}")
|
||||
cfs_params = op_data.get("instanceOperation", {}).get("cfsParams", [])
|
||||
print(f"[api_params] cfsParams count={len(cfs_params)}", flush=True)
|
||||
|
||||
result = []
|
||||
for p in cfs_params:
|
||||
dd = p.get("dataDescriptor")
|
||||
pv = p.get("paramValue")
|
||||
dv = p.get("defaultValue")
|
||||
print(f"[api_params] {p.get('svcOperationCfsParam')}: paramValue={pv!r} defaultValue={dv!r}", flush=True)
|
||||
result.append({
|
||||
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
|
||||
"name": p.get("svcOperationCfsParam", ""),
|
||||
"dataType": p.get("dataType", ""),
|
||||
"isRequired": p.get("isRequired", False),
|
||||
"defaultValue": p.get("paramValue"), # текущее значение из инстанса
|
||||
"defaultValue": pv, # текущее значение из инстанса
|
||||
"valueList": p.get("valueList"),
|
||||
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
||||
})
|
||||
print(f"[api_params] PREVIEW returning {len(result)} params", flush=True)
|
||||
return jsonify({"params": result, "previewOpUid": preview_op_uid})
|
||||
|
||||
# Без instanceUid — шаблонные значения по умолчанию
|
||||
print(f"[api_params] DEFAULT branch: template defaults", flush=True)
|
||||
data = _client().get(f"/instanceOperations/default/{op_id}")
|
||||
params = data["svcOperation"]["cfsParams"]
|
||||
result = []
|
||||
@@ -143,8 +152,12 @@ def api_params(op_id):
|
||||
"valueList": p.get("valueList"),
|
||||
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
||||
})
|
||||
print(f"[api_params] DEFAULT returning {len(result)} params", flush=True)
|
||||
return jsonify({"params": result})
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print(f"[api_params] EXCEPTION: {e}", flush=True)
|
||||
traceback.print_exc()
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user