Skip to content

"Error while copying content to a stream" when watching empty set #893

Closed
@nabsul

Description

@nabsul

When I attempt to watch for changes on a set of objects that is empty, the response body from the Kubernetes API is empty and causes an exception.

I am able to repro this in Linqpad with this code:

var cfg = KubernetesClientConfiguration.BuildDefaultConfig();
var client = new Kubernetes(cfg);
var result = await client.ListConfigMapForAllNamespacesWithHttpMessagesAsync(watch: true, labelSelector: "test-not-exist=val", timeoutSeconds: 10);

Notes:

  • For this error to repro, you must create a List request that returns zero results
  • I have observed this error with other data types, not just ConfigMap

The resulting error is:

HttpRequestException
Error while copying content to a stream.
Data
(0 items)
HelpLinknull
HResult-2147024858
InnerException
EndOfStreamException
Attempted to read past the end of the stream.
TargetSite
TargetSite
MessageAttempted to read past the end of the stream.
Data
(0 items)
InnerExceptionnull
HelpLinknull
SourceKubernetesClient
HResult-2147024858
StackTrace at k8s.LineSeparatedHttpContent.PeekableStreamReader.PeekLineAsync() in /_/src/KubernetesClient/LineSeparatedHttpContent.cs:line 180
at k8s.LineSeparatedHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context) in /_/src/KubernetesClient/LineSeparatedHttpContent.cs:line 30
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
MessageError while copying content to a stream.
SourceSystem.Net.Http
StackTrace at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpContent.WaitAndReturnAsync[TState,TResult](Task waitTask, TState state, Func`2 returnFunc)
at k8s.Kubernetes.CreateResultAsync[T](HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, Nullable`1 watch, CancellationToken cancellationToken) in /_/src/KubernetesClient/Kubernetes.cs:line 84
at k8s.AbstractKubernetes.ListConfigMapForAllNamespacesWithHttpMessagesAsync(Nullable`1 allowWatchBookmarks, String continueParameter, String fieldSelector, String labelSelector, Nullable`1 limit, Nullable`1 pretty, String resourceVersion, String resourceVersionMatch, Nullable`1 timeoutSeconds, Nullable`1 watch, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken) in /_/src/KubernetesClient.Basic/LibKubernetesGenerator/LibKubernetesGenerator.KubernetesClientSourceGenerator/Kubernetes.g.cs:line 972
at UserQuery.Main(), line 3
StatusCodenull
TargetSite
RuntimeMethodInfo
<LoadIntoBufferAsyncCore>d__63.MoveNext ()
NameMoveNext
DeclaringType
typeof (<LoadIntoBufferAsyncCore>d__63)
ReflectedType
typeof (<LoadIntoBufferAsyncCore>d__63)
Module
Module
CustomAttributes
(0 items)
IsCollectibleFalse
MetadataToken100664069
AttributesPrivateScope, Private, Final, Virtual, HideBySig, VtableLayoutMask
MethodImplementationFlagsManaged
CallingConventionStandard, HasThis
IsAbstractFalse
IsConstructorFalse
IsFinalTrue
IsHideBySigTrue
IsSpecialNameFalse
IsStaticFalse
IsVirtualTrue
IsAssemblyFalse
IsFamilyFalse
IsFamilyAndAssemblyFalse
IsFamilyOrAssemblyFalse
IsPrivateTrue
IsPublicFalse
IsConstructedGenericMethodFalse
IsGenericMethodFalse
IsGenericMethodDefinitionFalse
ContainsGenericParametersFalse
MethodHandle
RuntimeMethodHandle
System.RuntimeMethodHandle
Value140704672329552
IsSecurityCriticalTrue
IsSecuritySafeCriticalFalse
IsSecurityTransparentFalse
MemberTypeMethod
ReturnParameter
RuntimeParameterInfo
Void
AttributesNone
Member
RuntimeMethodInfo
<LoadIntoBufferAsyncCore>d__63.MoveNext ()
Namenull
ParameterType
typeof (Void)
Position-1
IsInFalse
IsLcidFalse
IsOptionalFalse
IsOutFalse
IsRetvalFalse
DefaultValuenull
RawDefaultValuenull
HasDefaultValueTrue
CustomAttributes
(0 items)
MetadataToken134217728
ReturnType
typeof (Void)
ReturnTypeCustomAttributes
ICustomAttributeProvider (RuntimeParameterInfo)
Void
AttributesNone
Member
RuntimeMethodInfo
<LoadIntoBufferAsyncCore>d__63.MoveNext ()
Namenull
ParameterType
typeof (Void)
Position-1
IsInFalse
IsLcidFalse
IsOptionalFalse
IsOutFalse
IsRetvalFalse
DefaultValuenull
RawDefaultValuenull
HasDefaultValueTrue
CustomAttributes
(0 items)
MetadataToken134217728

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions