Skip to content

Fix reflection FileDescriptorResponse dropping all but the last descriptor#117

Merged
ghostdogpr merged 1 commit into
mainfrom
fix/reflection-repeated-file-descriptor
Jul 9, 2026
Merged

Fix reflection FileDescriptorResponse dropping all but the last descriptor#117
ghostdogpr merged 1 commit into
mainfrom
fix/reflection-repeated-file-descriptor

Conversation

@ghostdogpr

@ghostdogpr ghostdogpr commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Problem

The gRPC reflection protocol (grpc.reflection.v1) defines:

message FileDescriptorResponse {
  repeated bytes file_descriptor_proto = 1;
}

When a reflection server answers a FileContainingSymbol/FileByFileName request, it returns one response whose file_descriptor_proto repeated field carries the requested file's descriptor plus all its transitively-imported files' descriptors — field number 1 emitted N times on the wire.

proteus modeled this as a singular Array[Byte]. Decoding N occurrences of a wire field into a singular register follows protobuf last-wins semantics, so every descriptor but the last was silently discarded. A caller could no longer rebuild the full descriptor set via FileDescriptor.buildFrom because the imported dependencies were missing.

The existing backend reflection tests only query grpc.reflection.v1.ServerReflection, whose .proto has no imports (exactly one descriptor returned), so the multi-descriptor collapse was never exercised.

Fix

Model the field as List[Array[Byte]] so the codec decodes all repeated file_descriptor_proto entries. Existing backend tests remain compatible (they assert _.nonEmpty, which holds for List too).

…iptor

The gRPC reflection protocol defines FileDescriptorResponse.file_descriptor_proto
as `repeated bytes`, carrying the requested file plus all its transitive imports.
proteus modeled it as a singular Array[Byte], so decoding a response with N
descriptors collapsed to last-wins and silently dropped every descriptor but one,
making the dependency set impossible to reconstruct.

Model it as List[Array[Byte]] so all repeated entries are retained.
@ghostdogpr ghostdogpr force-pushed the fix/reflection-repeated-file-descriptor branch from f7e199a to a0a8f7f Compare July 9, 2026 05:52
@ghostdogpr ghostdogpr merged commit 2e9775c into main Jul 9, 2026
3 checks passed
@ghostdogpr ghostdogpr deleted the fix/reflection-repeated-file-descriptor branch July 9, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant