{"record":{"id":"635884755949796f","repo":"googleapis/mcp-toolbox","slug":"g-is-not-an-allowed-value","errorCode":null,"errorMessage":"%g is not an allowed value","messagePattern":"%g is not an allowed value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/parameters/parameters.go","lineNumber":926,"sourceCode":"\nfunc (p *FloatParameter) Parse(v any) (any, error) {\n\tvar out float64\n\tswitch newV := v.(type) {\n\tdefault:\n\t\treturn nil, &ParseTypeError{p.Name, p.Type, v}\n\tcase float32:\n\t\tout = float64(newV)\n\tcase float64:\n\t\tout = newV\n\tcase json.Number:\n\t\tnewI, err := newV.Float64()\n\t\tif err != nil {\n\t\t\treturn nil, &ParseTypeError{p.Name, p.Type, v}\n\t\t}\n\t\tout = float64(newI)\n\t}\n\tif !p.IsAllowedValues(out) {\n\t\treturn nil, fmt.Errorf(\"%g is not an allowed value\", out)\n\t}\n\tif p.IsExcludedValues(out) {\n\t\treturn nil, fmt.Errorf(\"%g is an excluded value\", out)\n\t}\n\tif p.MinValue != nil && out < *p.MinValue {\n\t\treturn nil, fmt.Errorf(\"%g is under the minimum value\", out)\n\t}\n\tif p.MaxValue != nil && out > *p.MaxValue {\n\t\treturn nil, fmt.Errorf(\"%g is above the maximum value\", out)\n\t}\n\treturn out, nil\n}\n\nfunc (p *FloatParameter) GetAuthServices() []ParamAuthService {\n\treturn p.AuthServices\n}\n\nfunc (p *FloatParameter) GetDefault() any {","sourceCodeStart":908,"sourceCodeEnd":944,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/parameters/parameters.go#L908-L944","documentation":"FloatParameter.Parse rejects a float because it is not present in the parameter's allowedValues list. Tool authors can constrain numeric (double) parameters to a fixed set of acceptable values; any other number is rejected during parsing. The value parsed fine as a float — it just is not whitelisted.","triggerScenarios":"Calling a tool with a float argument not listed in the FloatParameter's allowedValues (yaml 'allowedValues:' or WithFloatAllowedValues). Example: allowedValues [0.5, 1.0, 2.5] but the request passes 0.7.","commonSituations":"LLMs inventing arbitrary decimal values for thresholds/ratios/temperature-like settings; clients sending computed floats that miss the whitelist; configs where allowedValues uses ints (1) while the caller sends floats (1.0 formatted differently upstream).","solutions":["Send one of the exact allowedValues listed in the tool's parameter schema/manifest","If the caller is an LLM, enumerate the valid values explicitly in the parameter description","If more values are needed, extend allowedValues in tools.yaml (or WithFloatAllowedValues) and redeploy","Beware floating-point formatting: send values that compare equal to listed ones (e.g. 1.0 not 0.9999)"],"exampleFix":"// before\nparams := map[string]any{\"threshold\": 0.7} // allowedValues are [0.5, 1.0]\n// after\nparams := map[string]any{\"threshold\": 1.0}","handlingStrategy":"validation","validationCode":"allowed := []float64{0.5, 1.0, 2.5}\nfunc validateAllowedFloat(v float64, allowed []float64) error {\n    for _, a := range allowed {\n        if v == a { return nil }\n    }\n    return fmt.Errorf(\"%g is not in allowedValues %v\", v, allowed)\n}","typeGuard":"func isAllowedFloat(v float64, allowed []float64) bool {\n    for _, a := range allowed { if v == a { return true } }\n    return false\n}","tryCatchPattern":"out, err := tool.Parse(params)\nif err != nil && strings.Contains(err.Error(), \"is not an allowed value\") {\n    // pick the nearest allowed value from the manifest and retry\n}","preventionTips":["Read allowedValues from the tool manifest and send exact matches","Beware float formatting: send 1.0 not 0.9999 for a listed 1.0","Enumerate valid decimals in the parameter description for LLMs","Extend allowedValues in config when new legitimate values are needed"],"tags":["go","validation","parameters","float"],"backgroundTag":"parameter-validation-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}