{"record":{"id":"2448a61d2efb2b16","repo":"googleapis/mcp-toolbox","slug":"can-t-convert-s-to-array-of-strings-w","errorCode":null,"errorMessage":"can't convert %s to array of strings: %w","messagePattern":"can't convert (.+?) to array of strings: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/searchcatalog/search_catalog.go","lineNumber":152,"sourceCode":"\ttokenStr string,\n\tsystemName string,\n\tparentParamName string,\n\ttypeMap map[string]string,\n\tprojectID string,\n\tgetCatalogClient func(ctx context.Context, token string) (*dataplexapi.CatalogClient, error),\n) ([]DataplexSearchResponse, error) {\n\tpageSize := int32(paramsMap[\"pageSize\"].(int))\n\tprompt, _ := paramsMap[\"prompt\"].(string)\n\n\tprojectIdSlice, err := parameters.ConvertAnySliceToTyped(paramsMap[\"projectIds\"].([]any), \"string\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't convert projectIds to array of strings: %w\", err)\n\t}\n\tprojectIds := projectIdSlice.([]string)\n\n\tparentIdSlice, err := parameters.ConvertAnySliceToTyped(paramsMap[parentParamName].([]any), \"string\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't convert %s to array of strings: %w\", parentParamName, err)\n\t}\n\tparentIds := parentIdSlice.([]string)\n\n\ttypesSlice, err := parameters.ConvertAnySliceToTyped(paramsMap[\"types\"].([]any), \"string\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't convert types to array of strings: %w\", err)\n\t}\n\ttypes := typesSlice.([]string)\n\n\tquery := ConstructSearchQuery(prompt, projectIds, parentIds, types, systemName)\n\n\treq := &dataplexpb.SearchEntriesRequest{\n\t\tQuery:          query,\n\t\tName:           fmt.Sprintf(\"projects/%s/locations/global\", projectID),\n\t\tPageSize:       pageSize,\n\t\tSemanticSearch: true,\n\t}\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/searchcatalog/search_catalog.go#L134-L170","documentation":"InvokeSearchCatalog converts the optional parent parameter (parentParamName, e.g. a location/collection parent resource list) from []any to []string. Non-string elements or an absent value fail the conversion and produce this formatted error naming the parameter. It enforces the tool's declared parameter types at runtime.","triggerScenarios":"Invoking search_catalog with the parent parameter containing non-string values or being nil when unmarshaled (null instead of an array).","commonSituations":"Agents sending null for optional list params; mixing numeric enum values into the parent list; schema drift between the client tool manifest and the server's expected types.","solutions":["Provide the parent param as a JSON array of strings, or omit it entirely only if the tool schema permits","Convert null to [] before sending","Check the tool manifest to confirm the exact parentParamName and its type","Add client-side validation that all list elements are strings"],"exampleFix":"// before\n{\"parent\": null}\n// after\n{\"parent\": [\"projects/my-project/locations/us-central1\"]}","handlingStrategy":"validation","validationCode":"if v, present := paramsMap[parentParamName]; present && v == nil { delete(paramsMap, parentParamName) }\n// or coerce: if v == nil { paramsMap[parentParamName] = []any{} }","typeGuard":"parents, ok := paramsMap[parentParamName].([]any); if ok && !allStrings(parents) { ... }","tryCatchPattern":"res, err := searchcatalog.InvokeSearchCatalog(ctx, src, params)\nif err != nil {\n\tif strings.Contains(err.Error(), fmt.Sprintf(\"can't convert %s\", parentParamName)) {\n\t\treturn fmt.Errorf(\"%s must be an array of strings\", parentParamName)\n\t}\n\treturn err\n}","preventionTips":["Never send null for optional list params — omit or send []","Keep client tool manifest types in sync with the server","Coerce numeric/enum values to strings before invoking"],"tags":["dataplex","searchcatalog","parameters","type-conversion"],"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"}