clockworklabs/SpacetimeDB · error · TypeError

View '${exportName}' can have at most one primaryKey() colum

Error message

View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}

What it means

Error "View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}" thrown in clockworklabs/SpacetimeDB.

Source

Thrown at crates/bindings-typescript/src/server/views.ts:273

  const { value: paramType } = ctx.resolveType(
    ctx.registerTypesRecursively(paramsBuilder)
  );

  ctx.moduleDef.views.push({
    sourceName: exportName,
    index: (anon ? ctx.anonViews : ctx.views).length,
    isPublic: opts.public,
    isAnonymous: anon,
    params: paramType,
    returnType,
  });

  // Runtime counterpart to `ValidateViewPrimaryKey`: the type-level check gives
  // users an early diagnostic in normal code, but this still protects dynamic
  // or widened builders and is the source of the raw module-def metadata.
  const primaryKeyColumns = viewPrimaryKeyColumns(ret);
  if (primaryKeyColumns.length > 1) {
    throw new TypeError(
      `View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}`
    );
  }
  if (primaryKeyColumns.length === 1) {
    ctx.moduleDef.viewPrimaryKeys.push({
      viewSourceName: exportName,
      columns: primaryKeyColumns,
    });
  }

  if (opts.name != null) {
    ctx.moduleDef.explicitNames.entries.push({
      tag: 'Function',
      value: {
        sourceName: exportName,
        canonicalName: opts.name,
      },
    });

View on GitHub (pinned to 524b4487d9)

When it happens

Trigger: Thrown at crates/bindings-typescript/src/server/views.ts:273 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/a91b5d6d83abb3dd. Report an issue: GitHub.