{"record":{"id":"0b86cb7c3b36ea89","repo":"microsoft/semantic-kernel","slug":"a-function-name-can-contain-only-ascii-letters-di","errorCode":null,"errorMessage":"A function name can contain only ASCII letters, digits, dashes and underscores: '{name}' is not a valid name.","messagePattern":"A function name can contain only ASCII letters, digits, dashes and underscores: '(.+?)' is not a valid name\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.MistralAI/Client/MistralFunction.cs","lineNumber":114,"sourceCode":"\n    #region private\n\n#if NET\n    [GeneratedRegex(\"^[0-9A-Za-z_-]*$\")]\n    private static partial Regex AsciiLettersDigitsUnderscoresRegex();\n#else\n    private static Regex AsciiLettersDigitsUnderscoresRegex() => s_asciiLettersDigitsUnderscoresRegex;\n    private static readonly Regex s_asciiLettersDigitsUnderscoresRegex = new(\"^[0-9A-Za-z_-]*$\");\n#endif\n\n    private static void ValidFunctionName(string name)\n    {\n        Verify.NotNull(name, nameof(name));\n        Verify.True(name.Length <= 64, \"The name of the function must be less than or equal to 64 characters.\", nameof(name));\n\n        if (!AsciiLettersDigitsUnderscoresRegex().IsMatch(name))\n        {\n            throw new ArgumentException($\"A function name can contain only ASCII letters, digits, dashes and underscores: '{name}' is not a valid name.\");\n        }\n    }\n\n    private static MistralParameters ToMistralParameters(KernelFunctionMetadata metadata)\n    {\n        var parameters = new MistralParameters();\n\n        if (metadata.Parameters is { Count: > 0 })\n        {\n            foreach (var parameter in metadata.Parameters)\n            {\n                parameters.Properties.Add(parameter.Name, parameter.Schema ?? GetDefaultSchemaForTypelessParameter(parameter.Description));\n                if (parameter.IsRequired)\n                {\n                    parameters.Required.Add(parameter.Name);\n                }\n            }\n        }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.MistralAI/Client/MistralFunction.cs#L96-L132","documentation":"Thrown by MistralFunction.ValidFunctionName when the function name does not match the pattern ^[0-9A-Za-z_-]*$ or exceeds 64 characters. Mistral's tool/function API only accepts names containing ASCII letters, digits, dashes, and underscores. This is an ArgumentException during tool registration.","triggerScenarios":"Registering a KernelFunction whose name contains spaces, dots, parentheses, non-ASCII (Unicode) characters, or is longer than 64 characters; importing a plugin with C# method names that include special characters.","commonSituations":"Plugin method names with dots like 'Get.User.Info'; localized function names with accented characters; auto-generated function names from descriptions or prompts that include spaces; very long descriptive method names.","solutions":["Rename the KernelFunction to use only [A-Za-z0-9_-] and keep it under 64 characters.","Use the KernelFunction attribute or method overloads to override the exposed name: [KernelFunction(\"get_user_info\")].","Sanitize function names before registering the plugin with Mistral."],"exampleFix":"// before\n[KernelFunction(\"Get User Info\")]\npublic string GetUserInfo() { ... }\n\n// after\n[KernelFunction(\"get_user_info\")]\npublic string GetUserInfo() { ... }","handlingStrategy":"validation","validationCode":"static readonly Regex ValidName = new(@\"^[0-9A-Za-z_-]{1,64}$\");\nif (!ValidName.IsMatch(functionName))\n    throw new InvalidOperationException($\"Invalid function name: {functionName}\");","typeGuard":"static bool IsValidMistralFunctionName(string name) =>\n    !string.IsNullOrEmpty(name) && name.Length <= 64 &&\n    Regex.IsMatch(name, @\"^[0-9A-Za-z_-]*$\");","tryCatchPattern":null,"preventionTips":["Use snake_case or kebab-case for function names exposed to LLMs.","Apply [KernelFunction(\"sanitized_name\")] when C# method names are unsuitable.","Sanitize auto-generated function names before registration."],"tags":["mistralai","function-name","tool-calling","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}