# Buggy code
def check_nw_ip_flow(
    cmd,
    client,
    vm,
    watcher_rg,
    watcher_name,
    direction,
    protocol,
    local,
    remote,
    resource_group_name=None,
    nic=None,
    location=None,
):
    VerificationIPFlowParameters = cmd.get_models("VerificationIPFlowParameters")

    local_ip_address, local_port = local.split(":")
    remote_ip_address, remote_port = remote.split(":")
    if not is_valid_resource_id(vm):
        vm = resource_id(
            subscription=get_subscription_id(cmd.cli_ctx),
            resource_group=resource_group_name,
            namespace="Microsoft.Compute",
            type="virtualMachines",
            name=vm,
        )

    if nic and not is_valid_resource_id(nic):
        nic = resource_id(
            subscription=get_subscription_id(cmd.cli_ctx),
            resource_group=resource_group_name,
            namespace="Microsoft.Network",
            type="networkInterfaces",
            name=nic,
        )

    return client.verify_ip_flow(
        watcher_rg,
        watcher_name,
        VerificationIPFlowParameters(
            target_resource_id=vm,
            direction=direction,
            protocol=protocol,
            local_port=local_port,
            remote_port=remote_port,
            local_ip_address=local_ip_address,
            remote_ip_address=remote_ip_address,
            target_nic_resource_id=nic,
        ),
    )


# Traceback (ValueError)
not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
Temp\pip-install-wl9gly17\knack\knack\cli.py, ln 206, in invoke
azure\cli\core\commands\__init__.py, ln 566, in execute
azure\cli\core\commands\__init__.py, ln 624, in _run_jobs_serially
azure\cli\core\commands\__init__.py, ln 617, in _run_job
Local\Temp\pip-install-wl9gly17\six\six.py, ln 693, in reraise
azure\cli\core\commands\__init__.py, ln 594, in _run_job
azure\cli\core\commands\__init__.py, ln 303, in __call__
azure-cli-core\azure\cli\core\__init__.py, ln 470, in default_command_handler
azure\cli\command_modules\network\custom.py, ln 3047, in check_nw_ip_flow
ValueError: not enough values to unpack (expected 2, got 1)

# Fixed code
def check_nw_ip_flow(
    cmd,
    client,
    vm,
    watcher_rg,
    watcher_name,
    direction,
    protocol,
    local,
    remote,
    resource_group_name=None,
    nic=None,
    location=None,
):
    VerificationIPFlowParameters = cmd.get_models("VerificationIPFlowParameters")

    try:
        local_ip_address, local_port = local.split(":")
        remote_ip_address, remote_port = remote.split(":")
    except:
        raise CLIError(
            "usage error: the format of the '--local' and '--remote' should be like x.x.x.x:port"
        )

    if not is_valid_resource_id(vm):
        if not resource_group_name:
            raise CLIError("usage error: --vm NAME --resource-group NAME | --vm ID")

        vm = resource_id(
            subscription=get_subscription_id(cmd.cli_ctx),
            resource_group=resource_group_name,
            namespace="Microsoft.Compute",
            type="virtualMachines",
            name=vm,
        )

    if nic and not is_valid_resource_id(nic):
        if not resource_group_name:
            raise CLIError("usage error: --nic NAME --resource-group NAME | --nic ID")

        nic = resource_id(
            subscription=get_subscription_id(cmd.cli_ctx),
            resource_group=resource_group_name,
            namespace="Microsoft.Network",
            type="networkInterfaces",
            name=nic,
        )

    return client.verify_ip_flow(
        watcher_rg,
        watcher_name,
        VerificationIPFlowParameters(
            target_resource_id=vm,
            direction=direction,
            protocol=protocol,
            local_port=local_port,
            remote_port=remote_port,
            local_ip_address=local_ip_address,
            remote_ip_address=remote_ip_address,
            target_nic_resource_id=nic,
        ),
    )