{"record":{"id":"5320dc9d1bfe24da","repo":"larksuite/cli","slug":"invalid-param-format","errorCode":null,"errorMessage":"invalid --param format","messagePattern":"invalid --param format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/event/consume.go","lineNumber":449,"sourceCode":"\tresult, err := f.Credential.ResolveToken(ctx, credential.NewTokenSpec(core.AsBot, appID))\n\tif err != nil {\n\t\tif _, ok := errs.ProblemOf(err); ok {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn \"\", errs.NewAuthenticationError(errs.SubtypeTokenMissing,\n\t\t\t\"resolve tenant access token: %s\", err).WithCause(err)\n\t}\n\tif result == nil || result.Token == \"\" {\n\t\treturn \"\", errs.NewAuthenticationError(errs.SubtypeTokenMissing,\n\t\t\t\"no tenant access token available for app %s\", appID).\n\t\t\tWithHint(\"check that app_secret is configured for this distribution\")\n\t}\n\treturn result.Token, nil\n}\n\n// Sentinels for errors.Is checks; call sites wrap them as typed ValidationError causes.\nvar (\n\terrInvalidParamFormat = errors.New(\"invalid --param format\") //nolint:forbidigo // sentinel, typed at call sites\n\terrOutputDirUnsafe    = errors.New(\"unsafe --output-dir\")    //nolint:forbidigo // sentinel, typed at call sites\n)\n\nfunc parseParams(raw []string) (map[string]string, error) {\n\tm := make(map[string]string)\n\tfor _, kv := range raw {\n\t\tk, v, ok := strings.Cut(kv, \"=\")\n\t\tif !ok || k == \"\" {\n\t\t\treturn nil, errs.NewValidationError(errs.SubtypeInvalidArgument,\n\t\t\t\t\"%s %q: expected key=value\", errInvalidParamFormat, kv).\n\t\t\t\tWithParam(\"--param\").\n\t\t\t\tWithCause(errInvalidParamFormat)\n\t\t}\n\t\tm[k] = v\n\t}\n\treturn m, nil\n}\n","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/cmd/event/consume.go#L431-L467","documentation":"errInvalidParamFormat is a sentinel error in cmd/event/consume.go for the --param flag of the event consume command. parseParams wraps it as a typed errs.ValidationError (SubtypeInvalidArgument, param --param) when an entry lacks a 'key=value' form or has an empty key. The sentinel exists so callers/tests can use errors.Is against the typed error's cause.","triggerScenarios":"Running the event consume command with --param entries like 'foo' (no '='), '=bar' (empty key), or empty strings; parseParams returns the sentinel and call sites emit the typed validation error.","commonSituations":"Shell quoting mishaps where '=' or value parts are lost; copy-pasted flags missing '='; scripting that builds --param from a list not validated for key=value shape.","solutions":["Pass each parameter as --param key=value with a non-empty key.","Check shell quoting so the '=' survives (quote the whole 'key=value' argument).","Inspect the %q message to see exactly which raw entry failed.","In scripts, validate entries with a cut/grep on '=' before invoking the CLI."],"exampleFix":"// before\nlark event consume --param eventId\n// after\nlark event consume --param eventId=123","handlingStrategy":"validation","validationCode":"// shell pre-validation before invoking the CLI\nfor p in \"$params[@]\"; do\n  case \"$p\" in\n    *=*) key=\"${p%%=*}\"; [ -n \"$key\" ] || { echo \"bad --param: $p\"; exit 1; } ;;\n    *)   echo \"bad --param (missing =): $p\"; exit 1 ;;\n  esac\ndone","typeGuard":"func isValidParam(kv string) bool {\n\tk, _, ok := strings.Cut(kv, \"=\")\n\treturn ok && k != \"\"\n}","tryCatchPattern":"// Go caller of parseParams\nparams, err := parseParams(raw)\nif err != nil {\n\tvar verr *errs.ValidationError\n\tif errors.As(err, &verr) && errors.Is(err, errInvalidParamFormat) {\n\t\t// reprompt / fix the offending --param entry\n\t}\n\treturn err\n}","preventionTips":["Always quote --param 'key=value' arguments in shells.","Validate key=value shape in scripts before invoking the CLI.","Read the %q-quoted offending entry in the error message."],"tags":["go","cli","flag-parsing"],"backgroundTag":"invalid-flag-argument","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}