{"record":{"id":"a338734a6fe4ea59","repo":"googleapis/mcp-toolbox","slug":"parameter-s-is-marked-for-embedding-but-has-a-n","errorCode":null,"errorMessage":"parameter '%s' is marked for embedding but has a non-string value (type: %T)","messagePattern":"parameter '(.+?)' is marked for embedding but has a non-string value \\(type: %T\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/parameters/parameters.go","lineNumber":196,"sourceCode":"\n\ttype ParamToEmbed struct {\n\t\tOriginalValue string\n\t\tIndex         int // The index in the original Parameters slice\n\t}\n\n\t// Map: modelName -> list of ParamToEmbed\n\tparametersToEmbed := make(map[string][]ParamToEmbed)\n\n\tfor i, p := range ps {\n\t\tmodelName := p.GetEmbeddedBy()\n\t\tif modelName == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Get parameter's value to be embedded\n\t\tvalueStr, ok := paramValues[i].Value.(string)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"parameter '%s' is marked for embedding but has a non-string value (type: %T)\", p.GetName(), paramValues[i].Value)\n\t\t}\n\n\t\tparametersToEmbed[modelName] = append(parametersToEmbed[modelName], ParamToEmbed{\n\t\t\tOriginalValue: valueStr,\n\t\t\tIndex:         i,\n\t\t})\n\t}\n\n\t// Batch embedding request sent to each model\n\tfor modelName, params := range parametersToEmbed {\n\t\tmodel, ok := pMgr.GetEmbeddingModel(modelName)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"embedding model does not exist: %s\", modelName)\n\t\t}\n\n\t\t// Extract only the string values for the API call\n\t\tstringBatch := make([]string, len(params))\n\t\tfor i, paramStr := range params {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/parameters/parameters.go#L178-L214","documentation":"EmbedParams collects parameters flagged for embedding (vector embedding of text) and requires their values to be strings. If a parameter marked for embedding arrives with a non-string value (number, bool, array, etc.), EmbedParams returns this error naming the parameter and its Go type.","triggerScenarios":"Invoking a tool whose config marks a parameter with embedding enabled (embeddingModel set) while the caller supplies a non-string value for that parameter, e.g. an integer instead of text.","commonSituations":"Clients sending numeric IDs or arrays where free text is expected; agent passing JSON numbers; schema drift after editing a tool config to add embedding to a previously non-string parameter.","solutions":["Send the embedding parameter as a plain string value","Cast/serialize the value to string on the client before invoking the tool","Remove the embedding flag from parameters that are not free-text, or convert the parameter type to string in the tool config","Validate tool arguments against the manifest before invoking"],"exampleFix":"// before\n{\"id\": 42}           // param marked for embedding\n// after\n{\"id\": \"42\"}        // or remove embedding from this param","handlingStrategy":"type-guard","validationCode":"func embeddingValuesValid(params []Param, values map[string]any) error {\n    for _, p := range params {\n        if p.ShouldEmbed {\n            if _, ok := values[p.Name].(string); !ok {\n                return fmt.Errorf(\"param %s must be a string\", p.Name)\n            }\n        }\n    }\n    return nil\n}","typeGuard":"func isEmbeddableString(v any) bool {\n    _, ok := v.(string)\n    return ok\n}","tryCatchPattern":"embedded, err := EmbedParams(...)\nif err != nil {\n    return nil, fmt.Errorf(\"embedding requires string parameter values: %w\", err)\n}","preventionTips":["Mark only free-text parameters for embedding","Coerce client values to string before invoking tools with embedding enabled","Keep embedding-flagged parameter types as string in the schema"],"tags":["parameters","embedding","type-mismatch"],"backgroundTag":"parameter-type-mismatch","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"}