Skip to content

Asset editors crash on Statamic 6: container.site.value is undefined (assets have no site) #126

Description

@jakobploens

Summary

On Statamic 6, opening any asset editor throws and the editor's fields never render:

Uncaught (in promise) TypeError: can't access property "replaceAll", this.container.site.value is undefined

Cause

resources/js/Workspace.js builds the presence channel from the container's site:

this.channelName = `${reference}.${this.container.site.value.replaceAll('.', '_')}`;

Assets are not site-scoped, so the asset publish-container has no sitecontainer.site.value is undefined → it throws during workspace init (the component's mounted hook), aborting the editor render.

resources/js/collaboration.js guards reference but not site:

Statamic.$events.$on('publish-container-created', container => {
    if (!container.reference.value) return;   // no site guard
    manager.addWorkspace(container);
});

The same unguarded access is also in initializeContainerWatcher().

Steps to reproduce

  1. Statamic 6 + statamic/collaboration 2.0.1, a single-site install.
  2. Open any asset editor: /cp/assets/browse/{container}/{path}/edit.
  3. The editor's fields don't render; the console shows the TypeError above.

Confirmed on multiple containers (a local disk container and a custom-disk container), so it's not container-specific — it affects all asset editing.

Suggested fix

Skip the workspace when there's no site (collaboration on assets isn't meaningful — the channel name requires one), e.g. in the publish-container-created handler:

if (!container.reference.value || !container.site?.value) return;

or guard/default container.site.value in Workspace.initializeEcho() (and the watcher).

Environment

  • statamic/cms 6.20.1
  • statamic/collaboration 2.0.1
  • Single-site install

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions