Fix: containerAttachState telemetry incorrectly shows "Detached" during container load#26539
Draft
Fix: containerAttachState telemetry incorrectly shows "Detached" during container load#26539
Conversation
… fix early telemetry logging Co-authored-by: markfields <12305068+markfields@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix initial attachmentData state to avoid 'Detached' value
Fix: containerAttachState telemetry incorrectly shows "Detached" during container load
Feb 25, 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.
When
Container.load()creates a newContainerinstance for loading an existing attached container, early telemetry logs reportedcontainerAttachState: "Detached"— incorrect since the container was never in a detached state.Description
attachmentDatawas initialized to{ state: AttachState.Detached }at field declaration, meaning every container — including those loading existing attached documents — started life reportingDetacheduntil the load flow setAttachedat line ~1617.Fix: Initialize
attachmentDatatoundefinedwhenloadPropsis provided (i.e., loading scenario), reflecting a genuinely unknown state during the brief pre-load window.Key changes:
container.ts:attachmentDatais nowAttachmentData | undefined. Initialized to{ state: Detached }only whenloadProps === undefined(new container creation paths).attachStategetter returnsAttachState | undefined. Updatedserialize(),getPendingLocalState(), andattach()to guard againstundefined. CastgetAttachStatelambda passed toContainerContextasAttachState(safe — context is instantiated only afterattachmentDatais set).IContainer.attachState(container-definitions): Type widened toAttachState | undefinedto match the new semantics.FluidContainer.attachState(fluid-static): RetainsAttachStatereturn type via non-null assertion —FluidContaineris only surfaced to callers after load completes, soundefinedis never observable here.Breaking Changes
IContainer.attachStateis nowAttachState | undefined(wasAttachState). This is a backward-incompatible change to the@legacy @betainterface. Callers that assign anIContainerto a variable typed against the old interface will need to handleundefined.FluidContainer.attachState(@public) is unchanged — still returnsAttachState.Reviewer Guidance
undefinedstate is only observable on the rawIContainerobject during the internal load flow. By the timeContainer.load()resolves and callers receive the container,attachStateis alwaysAttached.as AttachStatecast ingetAttachState(ContainerContext config) and the!inFluidContainerare safe by construction but worth a second look.serialize()guard now throws onundefinedattachmentData with the sameUsageErroras the attached/closed cases — message is slightly imprecise for that path but the path is unreachable via public API.Original prompt
Created from VS Code.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.