fix(protoc-gen-openapiv2): fix panic on enum resolution in nested messages#6367
Merged
johanbrandhorst merged 1 commit intogrpc-ecosystem:mainfrom Feb 17, 2026
Merged
Conversation
…sages (grpc-ecosystem#6366) Fix two bugs in collectReferencedNamesForCache() introduced by PR grpc-ecosystem#6315 that caused a panic ("can't resolve OpenAPI ref from typename") when a service method returned a message containing another message with an enum field, particularly with multi-component package names like "example.v1". Bug 1: Message FQMNs were pre-populated in the refs map before scanning services, causing collectNestedTypeFQNs to short-circuit on already-visited entries and miss nested enum types. Bug 2: The package filter compared only the first dot-component (e.g. "example") against the full package name (e.g. "example.v1"), which always failed for multi-component packages. Fixes grpc-ecosystem#6366 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
252c706 to
5e4e81d
Compare
johanbrandhorst
approved these changes
Feb 16, 2026
Collaborator
johanbrandhorst
left a comment
There was a problem hiding this comment.
This looks.. reasonable? This code is pretty hard to follow, but if this fixes the case supplied in the bug then I'm satisfied.
Collaborator
|
@printfn any chance you could pull this and try it out in your environment to confirm the fix? |
Contributor
|
The fix seems to work. I did notice that compared to 2.27.7 a bunch of the |
Collaborator
Hm, perhaps if you're using the opaque API? I'm not sure, but if they break anything please open a new issue. I'll merge this and get a release out with the fix, thanks! |
This was referenced Apr 23, 2026
fix(deps): vuln minor upgrades — 11 packages (minor: 7 · patch: 4) [server]
DataDog/temporalio-ui#27
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6366 —
protoc-gen-openapiv2panics with"can't resolve OpenAPI ref from typename"when messages reference enums or cross-package types (regression from #6315).Three bugs in
collectReferencedNamesForCache():Traversal order: Message FQMNs were pre-populated in the
refsmap before scanning services. SincecollectNestedTypeFQNsusesrefsfor cycle detection, it short-circuited on pre-populated entries and never discovered nested enum types. Fixed by moving message pre-population to after service scanning.Incomplete traversal: Only service method request/response types were traversed for nested types, but
renderMessagesAsDefinitionrenders all messages from the file. Cross-package types referenced by non-service messages were missing from the naming cache. Fixed by also callingcollectNestedTypeFQNson all messages from the current file.Package filter: The filter compared only the first dot-component (e.g.
"example") against the full multi-component package name (e.g."example.v1"), which always failed. Fixed by usingstrings.HasPrefix(trimmedName, currentPackage+".").Test plan
TestGenerateEnumInNestedMessageMultiComponentPackage— models the exact reproducer from the issue (single file, multi-component package, nested enum)TestGenerateCrossPackageMessageReference— tests cross-package message references (different proto packages)TestGenerateMultiFileNamingConsistency— no regression on$refand definition name mismatch forgoogle.rpc.Statuswhen processing multiple proto files with nestedStatustype #6308TestGenerateMergeFilesWithBodyAndPathParams— no regression on protoc-gen-openapiv2 panics when generating OpenAPI for services with messages in separate files (Protobuf Edition 2023) #6274go test ./protoc-gen-openapiv2/internal/genopenapi/...passes🤖 Generated with Claude Code