{"record":{"id":"fbb73d427aedfec2","repo":"flipped-aurora/gin-vue-admin","slug":"options","errorCode":null,"errorMessage":"options 参数是必需的","messagePattern":"options 参数是必需的","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/dictionary_generator.go","lineNumber":79,"sourceCode":"\t\t\tmcp.Description(\"字典描述\"),\n\t\t),\n\t)\n}\n\nfunc (d *DictionaryOptionsGenerator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n\targs := request.GetArguments()\n\n\tdictType, ok := args[\"dictType\"].(string)\n\tif !ok || dictType == \"\" {\n\t\treturn nil, errors.New(\"dictType 参数是必需的\")\n\t}\n\tfieldDesc, ok := args[\"fieldDesc\"].(string)\n\tif !ok || fieldDesc == \"\" {\n\t\treturn nil, errors.New(\"fieldDesc 参数是必需的\")\n\t}\n\toptionsStr, ok := args[\"options\"].(string)\n\tif !ok || optionsStr == \"\" {\n\t\treturn nil, errors.New(\"options 参数是必需的\")\n\t}\n\n\tvar options []DictionaryOption\n\tif err := json.Unmarshal([]byte(optionsStr), &options); err != nil {\n\t\treturn nil, fmt.Errorf(\"options 参数格式错误: %v\", err)\n\t}\n\tif len(options) == 0 {\n\t\treturn nil, errors.New(\"options 不能为空\")\n\t}\n\n\treq := &DictionaryGenerateRequest{\n\t\tDictType:    dictType,\n\t\tFieldDesc:   fieldDesc,\n\t\tOptions:     options,\n\t\tDictName:    stringValue(args[\"dictName\"]),\n\t\tDescription: stringValue(args[\"description\"]),\n\t}\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/dictionary_generator.go#L61-L97","documentation":"Thrown by DictionaryOptionsGenerator's Handle when the \"options\" argument is missing, empty, or not a string. options must be a JSON-encoded string (unmarshalled with json.Unmarshal) that is parsed into []DictionaryOption.","triggerScenarios":"Invoking dictionary_generator without \"options\", with an empty string, or passing an actual JSON array/object instead of a JSON-encoded string (which fails the args[\"options\"].(string) type assertion).","commonSituations":"Callers passing the options as a native JSON array rather than a stringified JSON string; agents omitting the field; empty options from templating.","solutions":["Pass \"options\" as a string containing valid JSON, e.g. \"[{\\\"label\\\":\\\"启用\\\",\\\"value\\\":1}]\" — not a raw array.","Ensure the string is non-empty and parses as a JSON array of {label, value} objects.","Fix argument-building code to JSON-encode the options slice into a string before the call."],"exampleFix":"// before\n{\"arguments\": {\"dictType\": \"sys_user_status\", \"fieldDesc\": \"用户状态\", \"options\": [{\"label\": \"启用\", \"value\": 1}]}}\n// after\n{\"arguments\": {\"dictType\": \"sys_user_status\", \"fieldDesc\": \"用户状态\", \"options\": \"[{\\\"label\\\":\\\"启用\\\",\\\"value\\\":1}]\"}}","handlingStrategy":"type-guard","validationCode":"let optionsStr = args[\"options\"]\nif (typeof optionsStr !== \"string\" || optionsStr === \"\") {\n  throw new Error(\"options must be passed as a non-empty JSON-encoded string\")\n}\nJSON.parse(optionsStr) // throws early if not valid JSON","typeGuard":"function hasOptionsString(args) {\n  if (typeof args.options !== \"string\" || args.options === \"\") return false\n  try {\n    const parsed = JSON.parse(args.options)\n    return Array.isArray(parsed)\n  } catch {\n    return false\n  }\n}","tryCatchPattern":"try {\n  await callTool(\"dictionary_generator\", { dictType, fieldDesc, options: JSON.stringify(optionList) })\n} catch (e) {\n  if (e.message.includes(\"options 参数\")) {\n    // re-send options as JSON.stringify(arrayOfOptionObjects)\n  }\n}","preventionTips":["Always JSON.stringify option arrays before putting them in tool arguments.","Do not pass native arrays/objects where the tool expects a JSON string.","Parse-check the string client-side before invoking the tool."],"tags":["mcp","missing-argument","json-string"],"backgroundTag":"missing-required-parameter","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}