[Schema Inaccuracy] Server fails to send 'slug' and 'name' fields for InstallationAccount, but in the generated code they're mandatory.

Open
#4,651 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
kotlin
Domain
api

Research direction

The affected schema is components.schemas.enterprise.required, reached through the /app/installations response and its installation account union. Start by checking the GHES 3.12 OpenAPI input at the listed remoteInputSpec, then verify the generated model/InstallationAccount.kt no longer requires name and slug. Done means appsListInstallations can deserialize the response without MissingFieldException.

Written by the indexing model from the issue text.

Description

documentation inaccuracy

Schema Inaccuracy

Server fails to send 'slug' and 'name' fields for model/InstallationAccount.kt, but in the generated code they're mandatory.

Expected

Fields 'slug' and 'name' for InstallationAccount should be optional, according to the server response, but not the Kotlin generated code.

These seem to need changing:
components.schemas.enterprise.required - remove (name, slug)

paths./app/installations.responses.200 refers to components/schemas/installation which has a union:

          "account": {
            "nullable": true,
            "anyOf": [
              {
                "$ref": "#/components/schemas/simple-user"
              },
              {
                "$ref": "#/components/schemas/enterprise"
              }
            ]
          },

Reproduction Steps

I'm calling AppsApi().appsListInstallations() and getting an exception from my Enterprise server: GitHub Enterprise Server 3.12.8

Caused by: kotlinx.serialization.MissingFieldException: Fields [name, slug] are required for type with serial name 'com.bumble.sdlc.github.model.InstallationAccount', but they were missing

I've looked at the response json, and they are indeed missing.

If I add ? to make them nullable, this particular issue is fixed.

remoteInputSpec = "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/ghes-3.12/ghes-3.12.json"

openapi-generator/.config:
{
    "library": "jvm-ktor",
    "dateLibrary": "java8",
    "serializationLibrary": "kotlinx_serialization",
    "enumPropertyNaming": "UPPERCASE",
    "omitGradleWrapper": "true",
    "omitGradlePluginVersions": "true"
}
Exception in thread "main" io.ktor.serialization.JsonConvertException: Illegal input: Fields [name, slug] are required for type with serial name 'com.bumble.sdlc.github.model.InstallationAccount', but they were missing at path: $[0].account
	at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:77)
	at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:51)
	at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:111)
	at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(SafeCollector.common.kt:109)
	at kotlinx.coroutines.flow.FlowKt__ReduceKt.firstOrNull(Reduce.kt:247)
	at kotlinx.coroutines.flow.FlowKt.firstOrNull(Unknown Source)
	at io.ktor.serialization.ContentConverterKt.deserialize(ContentConverter.kt:99)
	at io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt.ContentNegotiation$lambda$13$convertResponse(ContentNegotiation.kt:234)
	at io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt.access$ContentNegotiation$lambda$13$convertResponse(ContentNegotiation.kt:1)
	at io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invokeSuspend(ContentNegotiation.kt:249)
	at io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invoke(ContentNegotiation.kt)
	at io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invoke(ContentNegotiation.kt)
	at io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invokeSuspend(KtorCallContexts.kt:105)
	at io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invoke(KtorCallContexts.kt)
	at io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invoke(KtorCallContexts.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)
	at io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:1379)
	at io.ktor.client.HttpClient$4.invoke(HttpClient.kt)
	at io.ktor.client.HttpClient$4.invoke(HttpClient.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)
	at io.ktor.client.plugins.logging.ReceiveHook$Context.proceed(Logging.kt:290)
	at io.ktor.client.plugins.logging.LoggingKt$Logging$2$3.invokeSuspend(Logging.kt:209)
	at io.ktor.client.plugins.logging.LoggingKt$Logging$2$3.invoke(Logging.kt)
	at io.ktor.client.plugins.logging.LoggingKt$Logging$2$3.invoke(Logging.kt)
	at io.ktor.client.plugins.logging.ReceiveHook$install$1.invokeSuspend(Logging.kt:298)
	at io.ktor.client.plugins.logging.ReceiveHook$install$1.invoke(Logging.kt)
	at io.ktor.client.plugins.logging.ReceiveHook$install$1.invoke(Logging.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)
	at io.ktor.client.plugins.ReceiveError$install$1.invokeSuspend(HttpCallValidator.kt:149)
	at io.ktor.client.plugins.ReceiveError$install$1.invoke(HttpCallValidator.kt)
	at io.ktor.client.plugins.ReceiveError$install$1.invoke(HttpCallValidator.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)
	at io.ktor.util.pipeline.DebugPipelineContext.execute$ktor_utils(DebugPipelineContext.kt:63)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
	at io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:86)
	at com.bumble.sdlc.github.api.AppsApi.appsListInstallations(AppsApi.kt:1014)
	at com.bumble.sdlc.github.api.AppsApi$appsListInstallations$1.invokeSuspend(AppsApi.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at com.bumble.sdlc.github.client.GitHubMultiClientKt.main(GitHubMultiClient.kt:80)
	at com.bumble.sdlc.github.client.GitHubMultiClientKt.main(GitHubMultiClient.kt)
Caused by: kotlinx.serialization.MissingFieldException: Fields [name, slug] are required for type with serial name 'com.bumble.sdlc.github.model.InstallationAccount', but they were missing at path: $[0].account
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:95)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:78)
	at com.bumble.sdlc.github.model.Installation$$serializer.deserialize(Installation.kt:35)
	at com.bumble.sdlc.github.model.Installation$$serializer.deserialize(Installation.kt:35)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
	at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
	at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
	at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:165)
	at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:69)
	... 50 more
Caused by: kotlinx.serialization.MissingFieldException: Fields [name, slug] are required for type with serial name 'com.bumble.sdlc.github.model.InstallationAccount', but they were missing
	at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
	at com.bumble.sdlc.github.model.InstallationAccount.<init>(InstallationAccount.kt:40)
	at com.bumble.sdlc.github.model.InstallationAccount$$serializer.deserialize(InstallationAccount.kt:40)
	at com.bumble.sdlc.github.model.InstallationAccount$$serializer.deserialize(InstallationAccount.kt:40)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	... 66 more
Dominant language
No language data
Stars
1.6k
Forks
342
Avg merge
3h 33m
Merged PRs (30d)
51

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/rest-api-description

All issues in github/rest-api-description

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.