Skip to content

/health endpoint crashes with NotSupportedException on source-generated JSON serializer #37

@Aaronontheweb

Description

@Aaronontheweb

Description

The /health endpoint returns an anonymous type that is not registered in the source-generated JSON serializer context (SkillServer.Models.SkillServerJsonContext), causing every health check request to throw System.NotSupportedException.

Error

System.NotSupportedException: JsonTypeInfo metadata for type '<>f__AnonymousType13`2[System.String,System.DateTimeOffset]' was not provided by TypeInfoResolver of type '[Microsoft.AspNetCore.OpenApi.OpenApiJsonSchemaContext, SkillServer.Models.SkillServerJsonContext]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.
   at System.Text.Json.ThrowHelper.ThrowNotSupportedException_NoMetadataForType(Type type, IJsonTypeInfoResolver resolver)
   at Microsoft.AspNetCore.Http.HttpResultsHelper.WriteResultAsJsonAsync[TValue](...)

Impact

  • Kubernetes HTTP liveness/readiness probes targeting /health cause the pod to crash-loop
  • Workaround: use tcpSocket probes instead of httpGet probes

Reproduction

curl http://skillserver:8080/health

Suggested Fix

Replace the anonymous type in the health endpoint response with a named type registered in SkillServerJsonContext, or add Results.Ok("Healthy") as a plain string response.

Environment

  • Image: ghcr.io/netclaw-dev/skillserver:0.1.0
  • Runtime: Kubernetes (MicroK8s 1.32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions