{"record":{"id":"a166efac795a86ee","repo":"googleapis/mcp-toolbox","slug":"can-t-convert-types-to-array-of-strings-w","errorCode":null,"errorMessage":"can't convert types to array of strings: %w","messagePattern":"can't convert types to array of strings: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/searchcatalog/search_catalog.go","lineNumber":158,"sourceCode":") ([]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\n\tcatalogClient, err := getCatalogClient(ctx, tokenStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get catalog client: %w\", err)\n\t}\n\n\treturn ExecuteSearch(ctx, catalogClient, req, typeMap)","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/searchcatalog/search_catalog.go#L140-L176","documentation":"InvokeSearchCatalog converts the types parameter (Dataplex entry type filters such as TABLE, DATASET) from []any to []string using parameters.ConvertAnySliceToTyped. If elements are not strings the conversion fails with this wrapped error, preventing invalid type filters from reaching ConstructSearchQuery.","triggerScenarios":"Invoking search_catalog with types containing non-string values (numbers, booleans, null entries) or the key absent so the type assertion to []any fails.","commonSituations":"Clients omitting types (key missing) instead of sending an empty array; agents passing type objects/dicts instead of plain strings; casing mistakes are fine value-wise but only string type matters here.","solutions":["Send types as an array of strings, e.g. [\"TABLE\",\"VIEW\"], or [] if empty","Ensure the key exists (empty array rather than omitted) if the client always serializes it","Normalize any enum-like values to plain uppercase strings","Validate client-side that every element is a string before invoking"],"exampleFix":"// before\n{\"types\": [null, {\"type\": \"TABLE\"}]}\n// after\n{\"types\": [\"TABLE\"]}","handlingStrategy":"validation","validationCode":"func allStrings(v []any) bool {\n\tfor _, e := range v { if _, ok := e.(string); !ok { return false } }\n\treturn true\n}\n// require types (if present) to be []any of strings","typeGuard":"t, ok := paramsMap[\"types\"].([]any); if ok && !allStrings(t) { return errors.New(\"types must be strings\") }","tryCatchPattern":"res, err := searchcatalog.InvokeSearchCatalog(ctx, src, params)\nif err != nil {\n\tif strings.Contains(err.Error(), \"can't convert types\") {\n\t\treturn fmt.Errorf(\"types must be an array of strings: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Send types as [\"TABLE\",\"VIEW\"] style string arrays","Use [] rather than omitting the key when the client always serializes lists","Whitelist known Dataplex entry type strings before sending"],"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"}