microsoft/semantic-kernel · error · KernelException

Parsing of '{protoFileName}' .proto document has failed. Det

Error message

Parsing of '{protoFileName}' .proto document has failed. Details: {string.Join(";", errors.AsEnumerable())}

What it means

Thrown by ProtoDocumentParser when, after adding the .proto to a FileDescriptorSet and calling Process(), `descriptor.GetErrors()` returns one or more errors. The message joins all errors with ';'. This is a schema-level parse failure distinct from a missing file.

Source

Thrown at dotnet/src/Functions/Functions.Grpc/Protobuf/ProtoDocumentParser.cs:38

    /// </summary>
    /// <param name="protoDocument">The .proto document.</param>
    /// <param name="protoFileName">The .proto file logical name.</param>
    /// <returns>List of gRPC operations.</returns>
    public IList<GrpcOperation> Parse(Stream protoDocument, string protoFileName)
    {
        Verify.NotNull(protoDocument);
        Verify.NotNullOrWhiteSpace(protoFileName);

        using var textReader = new StreamReader(protoDocument);

        var descriptor = new FileDescriptorSet();
        descriptor.Add(protoFileName, source: textReader);
        descriptor.Process();

        var errors = descriptor.GetErrors();
        if (errors is not null && errors.Length != 0)
        {
            throw new KernelException($"Parsing of '{protoFileName}' .proto document has failed. Details: {string.Join(";", errors.AsEnumerable())}");
        }

        return this.GetGrpcOperations(descriptor.Files.Single());
    }

    /// <summary>
    /// Parses an .proto document and extracts gRPC operations.
    /// </summary>
    /// <param name="model">The .proto document model.</param>
    /// <returns>List of gRPC operations.</returns>
    private List<GrpcOperation> GetGrpcOperations(FileDescriptorProto model)
    {
        var operations = new List<GrpcOperation>();

        foreach (var service in model.Services)
        {
            foreach (var method in service.Methods)
            {

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Read the joined error details — they name the specific parse errors.
  2. Validate the .proto with `protoc` or a protobuf linter.
  3. Add missing `import` statements and fix syntax (e.g. declare `syntax = "proto3";`).

Example fix

// before
message Req { string id = 1 bad }
// after
message Req { string id = 1; }
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the .proto with `protoc --proto_path=. file.proto` before shipping.

Try / catch

try { /* parse */ }
catch (KernelException ex) when (ex.Message.Contains(".proto document has failed")) {
    // ex.Message lists parse errors; report them to the .proto author
}

Prevention

When it happens

Trigger: A .proto with syntax errors: undefined message types, missing semicolons, invalid field numbers, undeclared imports, malformed package/service definitions.

Common situations: Hand-editing a .proto and introducing a typo; .proto referencing types from another file without an import statement; protobuf version mismatch (proto2 vs proto3 syntax).

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/689b20c8793c2f71. Report an issue: GitHub.