{"record":{"id":"1e1a4ca01c070f32","repo":"fatedier/frp","slug":"errinvalidargument","errorCode":"ErrInvalidArgument","errorMessage":"invalid argument","messagePattern":"invalid argument","errorType":"error_code","errorClass":null,"httpStatus":400,"severity":"error","filePath":"client/configmgmt/types.go","lineNumber":12,"sourceCode":"package configmgmt\n\nimport (\n\t\"errors\"\n\t\"time\"\n\n\t\"github.com/fatedier/frp/client/proxy\"\n\tv1 \"github.com/fatedier/frp/pkg/config/v1\"\n)\n\nvar (\n\tErrInvalidArgument = errors.New(\"invalid argument\")\n\tErrNotFound        = errors.New(\"not found\")\n\tErrConflict        = errors.New(\"conflict\")\n\tErrStoreDisabled   = errors.New(\"store disabled\")\n\tErrApplyConfig     = errors.New(\"apply config failed\")\n)\n\ntype ConfigManager interface {\n\tReloadFromFile(strict bool) error\n\n\tReadConfigFile() (string, error)\n\tWriteConfigFile(content []byte) error\n\n\tGetProxyStatus() []*proxy.WorkingStatus\n\tIsStoreProxyEnabled(name string) bool\n\tStoreEnabled() bool\n\n\tGetProxyConfig(name string) (v1.ProxyConfigurer, bool)\n\tGetVisitorConfig(name string) (v1.VisitorConfigurer, bool)","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/client/configmgmt/types.go#L1-L30","documentation":"configmgmt.ErrInvalidArgument is the frpc config-manager sentinel for caller mistakes. Manager methods in client/config_manager.go wrap it (via %w) around concrete causes: empty config file path, empty request body, missing proxy/visitor name, type field missing in a submitted config, URL name not matching body name, or failed config validation. The frpc admin HTTP layer maps it to 400 Bad Request (client/http/controller.go:60).","triggerScenarios":"POST/PUT to frpc admin endpoints /api/config or /api/proxy|visitor with an empty body, a config lacking 'name' or 'type', a URL name that differs from the body name, or a payload that fails CompleteProxyConfigurers validation. ReloadFromFile/ReadConfigFile also wrap it when frpc was started with no config file path (-c flag / config path empty).","commonSituations":"Automating frpc config via the admin API and forgetting required fields; renaming a proxy in the body but not the URL; running frpc purely from flags so no config file exists; whitespace/JSON shape mistakes that fail strict validation.","solutions":["Match on errors.Is(err, configmgmt.ErrInvalidArgument) and read the suffix after the colon — it names the exact bad field","Ensure POST/PUT bodies include both name and type and that the URL name equals the body name","Pass a config file path (-c) when using file-based operations like ReadConfigFile/ReloadFromFile","Fix the validation error named in the message, then re-run validation locally before resubmitting"],"exampleFix":"// before\ncurl -X POST localhost:7400/api/proxy -d '{\"type\":\"tcp\"}' // 400 invalid argument: proxy name is required\n\n// after\ncurl -X POST localhost:7400/api/proxy -d '{\"type\":\"tcp\",\"name\":\"ssh\",\"remotePort\":22}'","handlingStrategy":"validation","validationCode":"// Validate before calling manager/admin APIs\nfunc validProxyPayload(p v1.TypedProxyConfig) error {\n    b := p.GetBaseConfig()\n    if b == nil || b.Name == \"\" { return fmt.Errorf(\"name is required\") }\n    if p.Type() == \"\" { return fmt.Errorf(\"type is required\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"err := mgr.CreateProxy(ctx, cfg)\nif err != nil {\n    if errors.Is(err, configmgmt.ErrInvalidArgument) {\n        return http.Error(w, err.Error(), http.StatusBadRequest) // message names the bad field\n    }\n    return err\n}","preventionTips":["Always fill name and type, and keep URL name == body name on PUT","Run CompleteProxyConfigurers + validation locally before submitting","Match on errors.Is(sentinel) rather than string comparison"],"tags":["go","frpc","config-management","validation","admin-api"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}