{"record":{"id":"c564f9fa8406fde1","repo":"googleapis/mcp-toolbox","slug":"invalid-or-missing-s-parameter-expected-a-stri","errorCode":null,"errorMessage":"invalid or missing '%s' parameter; expected a string","messagePattern":"invalid or missing '(.+?)' parameter; expected a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudhealthcare/common/util.go","lineNumber":49,"sourceCode":"const EnablePatientNameFuzzyMatchingKey = \"fuzzymatching\"\n\n// IncludeAttributesKey is the key used for DICOM search to include additional\n// tags in the response.\nconst IncludeAttributesKey = \"includefield\"\n\n// ValidateAndFetchStoreID validates the provided storeID against the allowedStores.\n// If only one store is allowed, it returns that storeID.\n// If multiple stores are allowed, it checks if the storeID parameter is in the allowed list.\nfunc ValidateAndFetchStoreID(params parameters.ParamValues, allowedStores map[string]struct{}) (string, error) {\n\tif len(allowedStores) == 1 {\n\t\tfor k := range allowedStores {\n\t\t\treturn k, nil\n\t\t}\n\t}\n\tmapParams := params.AsMap()\n\tstoreID, ok := mapParams[StoreKey].(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"invalid or missing '%s' parameter; expected a string\", StoreKey)\n\t}\n\tif len(allowedStores) > 0 {\n\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}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/common/util.go#L31-L67","documentation":"ValidateAndFetchStoreID extracts the `storeID` parameter from the invocation parameters and asserts it is a string. When the parameter is absent or is not a string (e.g. a number or object), this error is returned. If exactly one store is allowed by the source config, the parameter is not needed at all.","triggerScenarios":"Calling Invoke on a healthcare tool without a `storeID` parameter while the source allows zero or multiple DICOM/FHIR stores, or passing storeID as a non-string (e.g. JSON number).","commonSituations":"LLM omitting the storeID argument in a tool call; client sending `\"storeID\": 123` instead of a string; source configured with multiple allowed stores so the parameter becomes required.","solutions":["Include a string `storeID` parameter in the tool invocation.","Confirm the store ID exists in the Cloud Healthcare dataset and matches an allowed store if the source pins a list.","Configure the source with a single `allowedStores` entry if the tool should always use one store.","Validate client-side that storeID is a non-empty string before invoking."],"exampleFix":"// before\n{\"projectId\": \"p\", \"location\": \"us\", \"datasetId\": \"d\"}   // storeID missing\n// after\n{\"projectId\": \"p\", \"location\": \"us\", \"datasetId\": \"d\", \"storeID\": \"my-dicom-store\"}","handlingStrategy":"validation","validationCode":"function validateStoreParams(params) {\n  if (typeof params.storeID !== 'string' || params.storeID.length === 0) {\n    throw new Error(\"storeID must be a non-empty string\");\n  }\n  return params;\n}\n// use: validateStoreParams({storeID: \"my-dicom-store\", ...})","typeGuard":"function isStoreID(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Always pass storeID as a JSON string, never a number","If the source pins multiple stores, make storeID mandatory in your client","Prefer configuring a single allowed store when only one is used","Validate tool payloads against the tool's parameter schema before invoking"],"tags":["go","parameter-validation","cloud-healthcare"],"backgroundTag":"missing-required-argument","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"}