{"record":{"id":"264293acb57716cd","repo":"langfuse/langfuse","slug":"position-in-trace-filters-are-not-supported-in-pos","errorCode":null,"errorMessage":"Position-in-trace filters are not supported in postgres","messagePattern":"Position-in-trace filters are not supported in postgres","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/shared/src/server/filterToPrisma.ts","lineNumber":125,"sourceCode":"          \", \",\n        )}] `;\n        break;\n      case \"boolean\":\n        valuePrisma = Prisma.sql`${filter.value}`;\n        break;\n      case \"categoryOptions\":\n        // LFE-4815: Support category options in postgres\n        logger.warn(\"Category options not supported in postgres yet\");\n        throw new Error(\"Category options not supported in postgres yet\");\n      case \"booleanObject\":\n        logger.warn(\"Boolean object filters not supported in postgres yet\");\n        throw new Error(\"Boolean object filters not supported in postgres yet\");\n      case \"null\":\n        valuePrisma = Prisma.sql``;\n        break;\n      case \"positionInTrace\":\n        logger.warn(\"Position-in-trace filters are not supported in postgres\");\n        throw new Error(\"Position-in-trace filters not supported in postgres\");\n    }\n    const jsonKeyPrisma =\n      filter.type === \"stringObject\" || filter.type === \"numberObject\"\n        ? Prisma.sql`->>${filter.key}`\n        : Prisma.empty;\n    const [cast1, cast2] =\n      filter.type === \"numberObject\"\n        ? [Prisma.raw(\"cast(\"), Prisma.raw(\" as double precision)\")]\n        : [Prisma.empty, Prisma.empty];\n    const [valuePrefix, valueSuffix] =\n      filter.type === \"string\" || filter.type === \"stringObject\"\n        ? [\n            [\"contains\", \"does not contain\", \"ends with\"].includes(\n              filter.operator,\n            )\n              ? Prisma.raw(\"'%' || \")\n              : Prisma.empty,\n            [\"contains\", \"does not contain\", \"starts with\"].includes(","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/langfuse/langfuse/blob/59d92c7cf365150d10b753b5a0d1708902a2ed60/packages/shared/src/server/filterToPrisma.ts#L107-L143","documentation":"positionInTrace filters (latency/position conditions like 'first in trace' or 'root span') rely on ClickHouse window functions and have no Postgres translation, so filterToPrisma throws for this type. It is one of three explicitly unsupported filter types on Postgres, alongside categoryOptions and booleanObject.","triggerScenarios":"Requesting observations/spans filtered by positionInTrace (e.g. filterType 'positionInTrace' with operator like 'first'/'last') on a Postgres-backed deployment; common when a saved trace-detail view from a ClickHouse deployment is replayed against Postgres.","commonSituations":"Postgres-storage self-hosted installs using trace explorer filters like 'first event in trace' or 'root observation'; frontend code paths that unconditionally offer these filters regardless of storage backend.","solutions":["Drop the positionInTrace filter from the request or use ClickHouse-backed storage","Re-express the query without positional semantics (e.g. filter on parentObservationId is null for root spans) where equivalent","Hide/disable positionInTrace filter options in UIs when running against Postgres storage"],"exampleFix":"// before\nfilters: [{ type: 'positionInTrace', column: 'position', operator: 'equals', value: 'first' }]\n\n// after\nfilters: [{ type: 'string', column: 'parentObservationId', operator: 'equals', value: 'none' }] // root-span approximation","handlingStrategy":"validation","validationCode":"const POSTGRES_UNSUPPORTED = new Set(['categoryOptions', 'booleanObject', 'positionInTrace']);\nfilters = filters.filter(f => f.type !== 'positionInTrace'); // postgres deployments","typeGuard":"const isPostgresSupportedFilter = (f: Filter) => !['categoryOptions','booleanObject','positionInTrace'].includes(f.type);","tryCatchPattern":"try { query({ filters }); } catch (e) { if (/Position-in-trace filters are not supported/.test(e.message)) { fall back to parentObservationId-based filtering; } throw e; }","preventionTips":["Hide position-in-trace filter options on Postgres deployments","Express root/first-position semantics with parentObservationId where possible","Document which filter types are ClickHouse-only in your client wrappers"],"tags":["filters","postgres","unsupported-feature","position-in-trace"],"backgroundTag":"unsupported-filter-type","analyzedSha":"59d92c7cf365150d10b753b5a0d1708902a2ed60","analyzedAt":"2026-08-27T22:22:00.402Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}