Remove ComponentContext.documentId, Container.id
documentId is a Container level concept and should not be exposed via ComponentContext and ComponentRuntime.
Especially with detachedContainers, Components do not know (or should care) when the Container is attached and the documentId is not available before the Container is attached.
This issue has been automatically marked as stale because it has had no activity for 180 days. It will be closed if no further activity occurs within 8 days of this comment. Thank you for your contributions to Fluid Framework!
Reactivating, as this topic popped up in recent discussions.
@chensixx - any chance you can do an assessment here on how it's used and if it's possible to deprecate it? I'd try to break it into smaller work items:
- Remove it from packages/runtime, which means removal from ICotainerContext and client-api
- Look at how Container.id is used and if it can be removed over time. Key usages I see (in priority order):
- Remove it from IContainer & Container public API
- branch in attributes - I think we can remove it, but need to double check how it's used.
- getVersion() call - would be great over time to move to using undefined here for same purposes
- telemetry, using docId - we really need it. I think that's fine to leave as is, so I'd keep it as is, at least for now.
Moving to August with assumption that you (@chensixx) are not going to complete it this month. If it's not the case, please move it back :)
After first attempt of removing document id, I found one instance that's blocking removal: In document.ts, used by flowContainer, used in SharedText. This is also related to issue #2915 so I will fix 2915 first
@vladsud I have a PR that removes docId from IFluidDataStoreContext and IFluidDataStoreRuntime. is the next step removing docId from everywhere? Since you mentioned remove it from IContainer as well.
In the new container creation flow, the container ID, i.e. document ID, will be generated by the backend. We need a method of propagating this ID to the application. Consider the following application pattern:
// Create a new container in FRS
const container = await client.createContainer(containerSchema);
// Retrieve the new container ID
const containerId = container.id;
// Access the existing container in FRS
const container = await client.getContainer(containerId, containerSchema);
To support this scenario, we need to keep the container id attribute.
@alpaix, why URI is not enough? What if service does not have notion of document ID? Maybe other way to ask it - what is it used for? If developer needs some stable correlation ID, why not generate it for specific flow using whatever hashing logic it wants (like sha or crc over container URI)? Cause that's pretty much what happens today in ODSP (combination of driveID, itemID and maybe site name and hashing result), but even today we had a discussion of maybe changing algorithm there - we do not really want that to be a contract we have to keep stable - if user flow wants it, it ideally needs to generate one.
@vladsud at the framework core level the tenantId + documentId pair is used to access an existing container that was created earlier by the same application. No matter what document identification method the application utilizes it has to resolve it to the corresponding Fluid document ID, aka container ID. For this reason, the application should be capable of reading the container ID when it's attached to the storage.
@agarwal-navin
documentIdis a Container level concept and should not be exposed via ComponentContext and ComponentRuntime.
Does this mean the document/container ID attribute at the container level will be preserved?
Especially with detachedContainers, Components do not know (or should care) when the Container is attached and the
documentIdis not available before the Container is attached.
I agree that components should not care about the container status. Yet, the application that orchestrates container creation and loading flows should be fully aware of the current status and needs to get the underlying container ID when it's attached to the storage.
tenantId + documentId concepts do not exist at runtime or loader level. Only URI exists and that's the only source of truth RE accessing container / identify matching. It's easy to check - search for tenantID in packages/runtime//*.ts & packages/loader//*.ts - you will find only one reference that should not be there (there is an issue for that). There are some workflows that are hard and should be made easier (like identify comparison - if given URI is for given container), but they should be in the scope of URI resolver, NOT container or runtime.
So I do not see why container needs to care or take a dependency on such concepts.
If 3P SDK uses such concepts - such concepts should not leak into loader / runtime layers.
I'd add that if we think concept of containerID is useful, it should be exposed from URI resolver, and that's precisely what it is today:
public get id(): string {
return this._resolvedUrl?.id ?? "";
}
But I think we should try really hard not to have hard dependency on it, as it locks URI resolvers to never change algorithm we use to calculate it, and I'd rather see each induvial usage do its own calculation and own back-compatibility concerns around it / be more in control of keeping it the same over time. For example, URI resolve may chose hashing algorithm that has reasonable collision rate for telemetry purposes, but not acceptable for almost-unique identification of a file.
I think I got the idea. The loader takes an URL and pass it down to a driver to resolve and load a container. Somewhat similar to a DB connection string? And then the url resolver and the driver are responsible for parsing it and retrieving tenant and document ID components if applicable. This approach makes the container be driver/url/file agnostic.
The only problem here is how to communicate the container location URL generated by the driver and return it to the application.
That's correct, URI resolve is the one that completely abstracts these things from other layers, so for most part container / runtime do not care. There are certain exceptions to that rule that we saw, two comes to mind:
- runtime may optimize the flow if it knows that given URI is for same container, for example if PASTE content came from same container, then it might use direct references to objects without going through container load flow)
- Runtime may want to create a URI to a component, it needs help of URI resolver to have full path - see getAbsoluteUrl() APIs
But otherwise we do not expose URI resolver or any of its parts to runtime. Container is a slightly different, as it does have direct access to URI resolver, but I'd rather push developers to use directly URI resolver than project functionality from it to Container.
I assume this work will continue through Sept, so moving it to Sept. Feel free to move back if I'm wrong :)
@chensixx, any chance you can update this item with latest thinking / breakdown / ETA? I want to have a better handle of the work remaining, and when we think it will be completed.
Marking as an Epic. This work is staged into many steps and will be long-running.
the only 2 steps left should be 1. removing container.id and usages, 2. removing containerContext.id after 0.55 is released, then it will be done. also as Vlad mentioned, we can transition getVersions() to using undefined
@chensixx Heads up - When you merge that PR this issue will close, but from your last comment it sounds like this issue should live on until the final removal is done.