v2rayA/v2rayA · error · ErrInvalidParameter

invalid parameters

Error message

invalid parameters

What it means

Sentinel error ErrInvalidParameter (service/kernel/serverObj/serverObj.go:12) is returned whenever a proxy server URL or server object cannot be parsed into a valid ServerObj. Parsers for HTTP, SS, SSR, SOCKS, Trojan URLs and NewV2Ray all funnel malformed input into this single error so callers can compare with errors.Is. It signals that the user-supplied link or parameters are structurally invalid (bad URL, non-numeric port, missing required fields).

Source

Thrown at service/kernel/serverObj/serverObj.go:12

package serverObj

import (
	"fmt"
	"net/url"

	"github.com/v2rayA/v2rayA/conf"
	"github.com/v2rayA/v2rayA/kernel/coreObj"
	"github.com/v2rayA/v2rayA/kernel/v2ray/where"
)

var ErrInvalidParameter = fmt.Errorf("invalid parameters")

type ServerObj interface {
	Configuration(info PriorInfo) (c Configuration, err error)
	ExportToURL() string
	NeedPluginPort() bool
	ProtoToShow() string
	GetProtocol() string
	GetHostname() string
	GetPort() int
	GetName() string
	SetName(name string)
}

type Configuration struct {
	CoreOutbound            coreObj.OutboundObject
	ExtraOutbounds          []coreObj.OutboundObject
	PluginChain             string // The first is a server plugin, and the others are client plugins. Split by ",".
	UDPSupport              bool

View on GitHub (pinned to 71e5442fc5)

Solutions

  1. Re-check the share URL: ensure the scheme, host, and a numeric port are present (e.g. http://host:8080#name).
  2. Percent-encode special characters (spaces, #, ?) in the URL before passing it in.
  3. If the link came from a subscription, re-fetch the subscription; the entry may be truncated or base64 of the whole body rather than a per-node link.
  4. Inspect the error with errors.Is(err, serverObj.ErrInvalidParameter) to distinguish parse failures from network/other errors and log the offending input.

Example fix

// before
obj, err := serverObj.ParseHttpURL("http://example.com") // port missing -> ErrInvalidParameter
// after
obj, err := serverObj.ParseHttpURL("http://example.com:8080#my-proxy")
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(link)
if err != nil {
    return fmt.Errorf("bad proxy url: %w", err)
}
if _, err := strconv.Atoi(u.Port()); err != nil {
    return fmt.Errorf("proxy url needs a numeric port, got %q", u.Port())
}

Type guard

func isValidProxyURL(link string) bool {
    u, err := url.Parse(link)
    if err != nil || u.Host == "" {
        return false
    }
    _, err = strconv.Atoi(u.Port())
    return err == nil
}

Try / catch

if _, err := serverObj.ParseHttpURL(link); err != nil {
    if errors.Is(err, serverObj.ErrInvalidParameter) {
        log.Printf("skipping malformed node %q", link)
        return nil // or substitute a default
    }
    return err
}

Prevention

When it happens

Trigger: Calling ParseHttpURL/ParseSSURL/ParseSSRURL/ParseSocksURL/ParseTrojanURL or NewV2Ray with a string whose url.Parse fails (illegal characters, control chars), or whose port cannot be converted by strconv.Atoi (missing, empty, or non-numeric port, e.g. http://example.com/ with no :port and empty t.Port()).

Common situations: Pasting a subscription link truncated by a chat client or shell quoting (e.g. missing port after ':'), hand-writing a share URL without a port, URLs containing unencoded special characters like spaces or '#', or copying a subscription body line instead of a share link.

Related errors


AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05). Data as JSON: /api/errors/b8ea597ec77e7d64. Report an issue: GitHub.