{"record":{"id":"9bd5306cc2ecc1e5","repo":"googleapis/mcp-toolbox","slug":"t-is-not-an-allowed-value","errorCode":null,"errorMessage":"%t is not an allowed value","messagePattern":"%t is not an allowed value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/parameters/parameters.go","lineNumber":1024,"sourceCode":"\t}\n\treturn p\n}\n\nvar _ Parameter = &BooleanParameter{}\n\n// BooleanParameter is a parameter representing the \"boolean\" type.\ntype BooleanParameter struct {\n\tCommonParameter `yaml:\",inline\"`\n\tDefault         *bool `yaml:\"default\"`\n}\n\nfunc (p *BooleanParameter) Parse(v any) (any, error) {\n\tnewV, ok := v.(bool)\n\tif !ok {\n\t\treturn nil, &ParseTypeError{p.Name, p.Type, v}\n\t}\n\tif !p.IsAllowedValues(newV) {\n\t\treturn nil, fmt.Errorf(\"%t is not an allowed value\", newV)\n\t}\n\tif p.IsExcludedValues(newV) {\n\t\treturn nil, fmt.Errorf(\"%t is an excluded value\", newV)\n\t}\n\treturn newV, nil\n}\n\nfunc (p *BooleanParameter) GetAuthServices() []ParamAuthService {\n\treturn p.AuthServices\n}\n\nfunc (p *BooleanParameter) GetDefault() any {\n\tif p.Default == nil {\n\t\treturn nil\n\t}\n\treturn *p.Default\n}\n","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/parameters/parameters.go#L1006-L1042","documentation":"BooleanParameter.Parse rejects a boolean because it is not in the parameter's allowedValues list. Booleans parse strictly (only Go bool / JSON true/false are accepted); after a successful cast the value is checked against allowedValues, so a config that whitelists only true (or only false) will reject the other value. This is expected config-driven validation.","triggerScenarios":"Calling a tool with a boolean argument that is not listed in the BooleanParameter's allowedValues (yaml 'allowedValues:' or WithBooleanAllowedValues). Example: allowedValues [true] but the request passes false.","commonSituations":"Tool authors restricting flags to a single direction (e.g. only allow enabling a feature) and clients/LLMs sending the opposite; configs copied between tools where one whitelisted booleans and the other did not; agents toggling flags during planning.","solutions":["Send the boolean value listed in the tool's parameter schema/manifest (e.g. true when only true is allowed)","If the caller is an LLM, state the only permitted value in the parameter description","If both values should be accepted, remove allowedValues from the parameter in tools.yaml (or drop WithBooleanAllowedValues) and redeploy"],"exampleFix":"// before\nparams := map[string]any{\"dry_run\": false} // allowedValues are [true]\n// after\nparams := map[string]any{\"dry_run\": true}","handlingStrategy":"validation","validationCode":"allowed := []bool{true}\nfunc validateAllowedBool(v bool, allowed []bool) error {\n    for _, a := range allowed {\n        if v == a { return nil }\n    }\n    return fmt.Errorf(\"%t is not in allowedValues %v\", v, allowed)\n}","typeGuard":"func isAllowedBool(v bool, allowed []bool) 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    // flip to the allowed boolean from the manifest and retry\n}","preventionTips":["Check the parameter manifest for allowedValues before sending booleans","Send JSON booleans (true/false), never strings like \"true\"","Document the permitted value in the parameter description","Avoid whitelisting single booleans unless the restriction is intentional"],"tags":["go","validation","parameters","boolean"],"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"}