Conversation
…g/cpp-411-builder-panics-instead-of-returning-an-error
dwillson
approved these changes
Mar 20, 2026
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.
Description
Changed versionChangeBuilder.Build() (and its fluent delegate methods on typeBuilder, requestToNextVersionBuilder, and responseToPreviousVersionBuilder) from returning *VersionChange to returning (*VersionChange, error). The previous panic() when no types or custom transformers were configured is now a proper error return.
🎟 Issue(s)
A missing ForType() or custom transformer call caused a runtime panic, crashing the process rather than surfacing a recoverable error. This is P0 reliability: callers should be able to handle the misconfiguration without dying.
Fixes CPP-411
🧪 Functional Testing
Updated panic assertion in version_change_builder_test.go to assert on the returned error instead
Propagated error handling across ~75 call sites in version_change_test.go, integration_test.go, openapi/version_transformer_test.go, openapi/generator_test.go, and openapi/swag_integration_test.go
Updated all three example programs (basic, advanced, schema-generation) to handle the error return
go test ./... and go vet ./... pass clean
📸 Screenshots
📋 Checklist
examples/directory