{"record":{"id":"a91b5d6d83abb3dd","repo":"clockworklabs/SpacetimeDB","slug":"view-exportname-can-have-at-most-one-primaryk","errorCode":null,"errorMessage":"View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}","messagePattern":"View '(.+?)' can have at most one primaryKey\\(\\) column on its returned row type; found (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/server/views.ts","lineNumber":273,"sourceCode":"  const { value: paramType } = ctx.resolveType(\n    ctx.registerTypesRecursively(paramsBuilder)\n  );\n\n  ctx.moduleDef.views.push({\n    sourceName: exportName,\n    index: (anon ? ctx.anonViews : ctx.views).length,\n    isPublic: opts.public,\n    isAnonymous: anon,\n    params: paramType,\n    returnType,\n  });\n\n  // Runtime counterpart to `ValidateViewPrimaryKey`: the type-level check gives\n  // users an early diagnostic in normal code, but this still protects dynamic\n  // or widened builders and is the source of the raw module-def metadata.\n  const primaryKeyColumns = viewPrimaryKeyColumns(ret);\n  if (primaryKeyColumns.length > 1) {\n    throw new TypeError(\n      `View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}`\n    );\n  }\n  if (primaryKeyColumns.length === 1) {\n    ctx.moduleDef.viewPrimaryKeys.push({\n      viewSourceName: exportName,\n      columns: primaryKeyColumns,\n    });\n  }\n\n  if (opts.name != null) {\n    ctx.moduleDef.explicitNames.entries.push({\n      tag: 'Function',\n      value: {\n        sourceName: exportName,\n        canonicalName: opts.name,\n      },\n    });","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-typescript/src/server/views.ts#L255-L291","documentation":"Error \"View '${exportName}' can have at most one primaryKey() column on its returned row type; found ${primaryKeyColumns.join(', ')}\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/bindings-typescript/src/server/views.ts:273 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}