{"record":{"id":"9e58820bd2e43117","repo":"XX-net/XX-Net","slug":"api-s-fail-s","errorCode":null,"errorMessage":"api:%s fail:%s","messagePattern":"api:(.+?) fail:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"code/default/x_tunnel/local/proxy_session.py","lineNumber":1214,"sourceCode":"            g.last_api_error = reason\n            return False, reason\n\n        content = decrypt_data(content)\n        if isinstance(content, memoryview):\n            content = content.tobytes()\n\n        content = utils.to_str(content)\n        try:\n            info = json.loads(content)\n        except Exception as e:\n            g.last_api_error = \"parse json fail\"\n            xlog.warn(\"api:%s parse json:%s fail:%r\", path, content, e)\n            return False, \"parse json fail\"\n\n        res = info[\"res\"]\n        if res != \"success\":\n            g.last_api_error = info[\"reason\"]\n            xlog.warn(\"api:%s fail:%s\", path, info[\"reason\"])\n            return False, info[\"reason\"]\n\n        xlog.info(\"api:%s success t:%d\", path, time_cost * 1000)\n        g.last_api_error = \"\"\n        return True, info\n    except Exception as e:\n        xlog.exception(\"order e:%r\", e)\n        g.last_api_error = \"%r\" % e\n        return False, \"except:%r\" % e\n\n\ncenter_login_process = False\n\n\ndef get_app_name():\n    app_info_file = os.path.join(root_path, os.path.pardir, \"app_info.json\")\n    try:\n        with open(app_info_file, \"r\") as fd:","sourceCodeStart":1196,"sourceCodeEnd":1232,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_session.py#L1196-L1232","documentation":"The control-plane API returned valid JSON but info['res'] != 'success' — the server rejected the operation (e.g. wrong password, insufficient funds, invalid order). g.last_api_error is set to the server's reason and call_api returns (False, reason).","triggerScenarios":"req_transfer_handler with insufficient balance; req_reset_password with bad old password; req_order_handler with invalid plan/params; check_report_status on unknown report.","commonSituations":"Insufficient account balance for a transfer, expired/invalid order parameters, wrong credentials supplied to the operation.","solutions":["Read the logged reason string — it's the server's own explanation (e.g. 'no enough money')","Fix the operation parameters (amounts, passwords, order IDs)","Check account balance/state with request_balance first","Retry after correcting the underlying account issue"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"ok, info = call_api('/api/balance')\nif not ok:\n    abort_operation(info)  # reason available before attempting transfer","typeGuard":null,"tryCatchPattern":"ok, reason = call_api(path)\nif not ok and reason != 'parse json fail':\n    show_user_error(reason)  # server business rejection","preventionTips":["Validate operation inputs (amounts, passwords) client-side first","Check balance/state APIs before mutating calls"],"tags":["x-tunnel","api","business-error"],"backgroundTag":"api-request-rejected","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}