Skip to content

Nested child documents are not properly deserialized #2969

@yGuy

Description

@yGuy

I have a project that includes markdown documents that have children defined in their front-matter,
however after deserializing my project json, it seems the document reflections cannot be found anymore.

I believe to have found the issue here:

this.children = de.reviveMany(obj.children, (obj) => de.reflectionBuilders.document(this, obj));

This just deserialized the object, but does no registration and ID book-keeping.

I think this should rather be similar to what de.constructReflection is doing, which is used e.g. in ContainerReflection's fromObject implementation when its children get revived:

Here is my suggested fix:

        this.children = de.reviveMany(obj.children, (obj) => {
            const result = de.reflectionBuilders.document(this, obj)
            de.oldIdToNewId[obj.id] = result.id;
            de.project.registerReflection(result, undefined, undefined);
            return result;
        });

With this hack (? we should probably call constructReflection in a perfect world and set the activeReflection stack accordingly), instead of just deserializing the object, the id bookkeeping is performed and the reflection is actually registered in the project (but with the "undefined"s, this still might not be correct), so this needs more thought by someone who better understands the code.

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