{"record":{"id":"f6e1e07523ee9338","repo":"googleapis/mcp-toolbox","slug":"can-t-convert-s-to-array-of-strings-s","errorCode":null,"errorMessage":"can't convert '%s' to array of strings: %s","messagePattern":"can't convert '(.+?)' to array of strings: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudhealthcare/common/util.go","lineNumber":70,"sourceCode":"\t\tif _, ok := allowedStores[storeID]; !ok {\n\t\t\treturn \"\", fmt.Errorf(\"store ID '%s' is not in the list of allowed stores\", storeID)\n\t\t}\n\t}\n\treturn storeID, nil\n}\n\n// ParseDICOMSearchParameters extracts the search parameters for various DICOM\n// search methods.\nfunc ParseDICOMSearchParameters(params parameters.ParamValues, paramKeys []string) ([]googleapi.CallOption, error) {\n\tvar opts []googleapi.CallOption\n\tfor k, v := range params.AsMap() {\n\t\tif k == IncludeAttributesKey {\n\t\t\tif _, ok := v.([]any); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid '%s' parameter; expected a string array\", k)\n\t\t\t}\n\t\t\tattributeIDsSlice, err := parameters.ConvertAnySliceToTyped(v.([]any), \"string\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"can't convert '%s' to array of strings: %s\", k, err)\n\t\t\t}\n\t\t\tattributeIDs := attributeIDsSlice.([]string)\n\t\t\tif len(attributeIDs) != 0 {\n\t\t\t\topts = append(opts, googleapi.QueryParameter(k, strings.Join(attributeIDs, \",\")))\n\t\t\t}\n\t\t} else if k == EnablePatientNameFuzzyMatchingKey {\n\t\t\tif _, ok := v.(bool); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid '%s' parameter; expected a boolean\", k)\n\t\t\t}\n\t\t\topts = append(opts, googleapi.QueryParameter(k, fmt.Sprintf(\"%t\", v.(bool))))\n\t\t} else if slices.Contains(paramKeys, k) {\n\t\t\tif _, ok := v.(string); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid '%s' parameter; expected a string\", k)\n\t\t\t}\n\t\t\tif v.(string) != \"\" {\n\t\t\t\topts = append(opts, googleapi.QueryParameter(k, v.(string)))\n\t\t\t}\n\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/common/util.go#L52-L88","documentation":"After the array check passes for `includefield`, ConvertAnySliceToTyped attempts to coerce every element to a string. If any element is not a string-convertible value, this wrapped error is returned, aborting parameter parsing for the DICOM search call.","triggerScenarios":"`includefield` is an array but contains non-string elements, e.g. [123] or [null, \"00100010\"].","commonSituations":"LLM emitting numeric DICOM tags without quoting; mixed-type arrays from dynamic client code; nulls injected into the array.","solutions":["Make every element of `includefield` a quoted string, e.g. [\"00100010\"].","Filter out null/undefined entries before sending.","Convert numeric tags to their zero-padded string form client-side.","Inspect the inner ConvertAnySliceToTyped message in the error for the offending element."],"exampleFix":"// before\n{\"includefield\": [1048848]}\n// after\n{\"includefield\": [\"00100010\"]}","handlingStrategy":"validation","validationCode":"function coerceTagStrings(arr) {\n  return arr.map(x => typeof x === 'string' ? x : String(x).padStart(8, '0'));\n}\n// then verify: coerced.every(x => /^\\d{8}$/.test(x))","typeGuard":"function isAllStrings(arr) { return Array.isArray(arr) && arr.every(x => typeof x === 'string' && x !== ''); }","tryCatchPattern":null,"preventionTips":["Quote DICOM tag IDs in JSON payloads; never send them as numbers","Filter null/undefined entries out of attribute arrays","Zero-pad numeric tags to their 8-digit string form","Test parameter serialization with representative payloads"],"tags":["go","parameter-validation","dicom","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"}