different-ai/openwork · error

OpenWork server has no workspace matching ${directory}.

Error message

OpenWork server has no workspace matching ${directory}.

What it means

createWorkspaceStore resolves an OpenWork workspace by querying the server for workspaces matching a local directory. When discovery succeeds but returns no workspace whose id can be used (discovered?.id falsy) and a directory was supplied, it throws stating the server has no workspace matching that directory. This is a lookup miss, not a transport error.

Source

Thrown at apps/desktop/electron/workspace-store.mjs:1024

    const openworkHostUrl = remoteType === "openwork"
      ? stripOpenworkWorkspaceMount(rawOpenworkHostUrl ?? baseUrl)
      : rawOpenworkHostUrl;
    const openworkWorkspaceId = typeof input.openworkWorkspaceId === "string" && input.openworkWorkspaceId.trim()
      ? input.openworkWorkspaceId.trim()
      : remoteType === "openwork"
        ? parseOpenworkWorkspaceIdFromUrl(rawOpenworkHostUrl) || parseOpenworkWorkspaceIdFromUrl(baseUrl)
        : null;
    let resolvedOpenworkWorkspaceId = openworkWorkspaceId;
    let resolvedOpenworkWorkspaceName = input.openworkWorkspaceName ?? null;
    if (remoteType === "openwork" && !resolvedOpenworkWorkspaceId) {
      const discovered = await discoverOpenworkWorkspace({
        hostUrl: openworkHostUrl ?? baseUrl,
        token: input.openworkToken,
        hostToken: input.openworkHostToken,
        directory,
      });
      if (!discovered?.id) {
        throw new Error(
          directory
            ? `OpenWork server has no workspace matching ${directory}.`
            : "OpenWork server returned no workspaces.",
        );
      }
      resolvedOpenworkWorkspaceId = String(discovered.id).trim();
      resolvedOpenworkWorkspaceName = openworkWorkspaceDisplayName(discovered);
    }
    const id = remoteType === "openwork"
      ? openworkRemoteWorkspaceId(openworkHostUrl ?? baseUrl, resolvedOpenworkWorkspaceId)
      : remoteWorkspaceId(baseUrl, directory);
    const workspace = normalizeWorkspaceEntry({
      id,
      name: String(input.displayName ?? resolvedOpenworkWorkspaceName ?? "Remote workspace"),
      displayName: input.displayName ?? null,
      path: directory ?? "",
      preset: "remote",
      workspaceType: "remote",

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Create the workspace on the OpenWork server for that directory, or omit/adjust directory so discovery can match.
  2. Compare the exact directory string the server knows (path normalization, trailing slash, case) with what you pass.
  3. Confirm you are pointed at the correct hostUrl/org that actually owns this workspace.

Example fix

// before
directory: "/Users/me/project/"  // trailing slash: no server match
// after
directory: "/Users/me/project"
Defensive patterns

Strategy: validation

Validate before calling

const normalized = path.resolve(directory); // strip trailing separators/symlink noise
if (!normalized || normalized === "/") throw new Error("A valid local directory is required");
// confirm the server knows this path before wiring the store:
const ws = await discoverWorkspaces({ hostUrl, token, directory: normalized });
if (!ws?.id) throw new Error(`No server workspace for ${normalized}`);

Type guard

function hasDiscoveredWorkspace(d) {
  return typeof d === "object" && d !== null && d.id !== undefined && d.id !== null && String(d.id).trim() !== "";
}

Try / catch

try {
  await createWorkspaceStore({ directory, openworkToken, openworkHostUrl });
} catch (err) {
  if (err.message.startsWith("OpenWork server has no workspace matching")) {
    // offer to create/register the workspace on the server
  } else throw err;
}

Prevention

When it happens

Trigger: Passing input.directory (plus hostUrl/token) to workspace store creation when the OpenWork server has no workspace registered for that exact directory path.

Common situations: The workspace was created only locally and never registered on the server; the directory string differs in case, trailing slash, or symlinked path from what the server stores; connecting to the wrong Den org/server.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/344bf89b534664f3. Report an issue: GitHub.