XX-net/XX-Net · error

api:%s fail:%s

Error message

api:%s fail:%s

What it means

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).

Source

Thrown at code/default/x_tunnel/local/proxy_session.py:1214

            g.last_api_error = reason
            return False, reason

        content = decrypt_data(content)
        if isinstance(content, memoryview):
            content = content.tobytes()

        content = utils.to_str(content)
        try:
            info = json.loads(content)
        except Exception as e:
            g.last_api_error = "parse json fail"
            xlog.warn("api:%s parse json:%s fail:%r", path, content, e)
            return False, "parse json fail"

        res = info["res"]
        if res != "success":
            g.last_api_error = info["reason"]
            xlog.warn("api:%s fail:%s", path, info["reason"])
            return False, info["reason"]

        xlog.info("api:%s success t:%d", path, time_cost * 1000)
        g.last_api_error = ""
        return True, info
    except Exception as e:
        xlog.exception("order e:%r", e)
        g.last_api_error = "%r" % e
        return False, "except:%r" % e


center_login_process = False


def get_app_name():
    app_info_file = os.path.join(root_path, os.path.pardir, "app_info.json")
    try:
        with open(app_info_file, "r") as fd:

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Read the logged reason string — it's the server's own explanation (e.g. 'no enough money')
  2. Fix the operation parameters (amounts, passwords, order IDs)
  3. Check account balance/state with request_balance first
  4. Retry after correcting the underlying account issue
Defensive patterns

Strategy: validation

Validate before calling

ok, info = call_api('/api/balance')
if not ok:
    abort_operation(info)  # reason available before attempting transfer

Try / catch

ok, reason = call_api(path)
if not ok and reason != 'parse json fail':
    show_user_error(reason)  # server business rejection

Prevention

When it happens

Trigger: 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.

Common situations: Insufficient account balance for a transfer, expired/invalid order parameters, wrong credentials supplied to the operation.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/9e58820bd2e43117. Report an issue: GitHub.