fix: keep the full factory name of a go model ending in able - #8110
Merged
Vincent Biret (baywet) merged 1 commit intoAug 31, 2026
Merged
Conversation
The go writer names a model's inserted interface by appending able, and GetImportedStaticMethodName recovered the model name for factory references by trimming that suffix off the rendered type name. The round trip is lossy for a model whose own name ends in able: an error mapping for ProviderUnavailable emitted CreateProviderUnavailFromDiscriminatorValue, a symbol that is never generated, so the whole package failed to compile. Error mappings (and property factories) reference the model class directly rather than the interface, which is why only these call sites were hit. Trim the suffix only when the type does not resolve to a model class: the inserted interfaces and unresolved names keep today's behavior, a class whose own name ends in able keeps its name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Go3AyndcGwv5tFTwo9aBfy
Vincent Biret (baywet)
approved these changes
Aug 31, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution!
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Go codegen defect where model names ending in able caused incorrect Create...FromDiscriminatorValue factory references (due to over-aggressive suffix trimming), leading to generated clients that don’t compile.
Changes:
- Updates Go
GetImportedStaticMethodNameto trim theablesuffix only when the type does not resolve to aCodeClass, preserving full class names likeProviderUnavailable. - Adds a Go writer regression test covering both: (1) a model class whose name ends with
ableand (2) an inserted model interface type that should still be trimmed. - Documents the fix in
CHANGELOG.mdunder Unreleased.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Kiota.Builder/Writers/Go/GoConventionService.cs |
Prevents erroneous able trimming when the type resolves to a model class, fixing broken factory symbol references in Go output. |
tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs |
Adds regression coverage ensuring class-names-with-able keep full factory names while interface types still trim correctly. |
CHANGELOG.md |
Records the Go fix and its impact under Unreleased/Changed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
A go client generated from a document containing a model whose name ends in
abledoes notcompile. The model itself is generated correctly:
but every error mapping that references it asks for a different symbol, with the trailing
ablegone:One schema name breaks the build of the whole package, so every operation in the client is
unusable, not just the endpoint that maps the error. Any name ending in
abletriggers it —ProviderUnavailable,Cancelable,Immutable,Table,Available— and only go isaffected: the same document generates correctly for the other languages.
(This may be the same defect as #2955, closed in 2023 without a recorded root cause — same
symptom, an undefined
Create...FromDiscriminatorValuein a go request builder.)Root cause
The go writer names a model's inserted interface by appending
able(Domain→Domainable), andGoConventionService.GetImportedStaticMethodNamerecovers the factoryname from the rendered type name by trimming that suffix back off. The refiner only rewrites
request executor return types and request bodies to the interfaces
(
CopyModelClassesAsInterfaces); an error mapping (and a property factory) still pointsat the model class. For those, the rendered name is the model's own name — and when that
name itself ends in
able, the trim eats part of it:ProviderUnavailablecannot be toldapart from the interface of a model called
ProviderUnavail, and the trim wins.Changes Made
GetImportedStaticMethodNameonly trims the suffix when the type does not resolve toa model class (
code is not CodeType { TypeDefinition: CodeClass }). Types that resolveto the inserted interface — and unresolved names, preserving today's behavior for them —
are trimmed exactly as before; a model class keeps its full name.
WritesRequestExecutorBodyForErrorModelNamedWithAbleSuffixcovering both sides:a class named
ProviderUnavailablekeeps its name in the factory reference, and a mappingthrough a model interface (
Error5XXable) still trims toCreateError5XX....Testing
The full
Kiota.Builder.Testssuite passes: 2291 passed, 0 failed.Reproduction, before/after. A minimal document with an error schema named
ProviderUnavailablereferenced from a 503 response, generated with-l goand compiledwith go 1.25:
go build ./...CreateProviderUnavailFromDiscriminatorValueundefined: ...CreateProviderUnavailFromDiscriminatorValueCreateProviderUnavailableFromDiscriminatorValueA production document of ≈100 operations (which is where this was found) generated
with this branch compiles cleanly with
go build ./....Generated with Claude Code