From 9b838ec01559e4c3e4e40372a2bd1a22638e0bda Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Thu, 19 Feb 2026 15:47:40 +0200 Subject: [PATCH] fix(linear): use .astext for JSONB text extraction in _resolve_issue cast(document_metadata["key"], String) generates CAST(col->'key' AS TEXT) which preserves JSON string quotes (e.g. '"Fix login bug"'), causing case-insensitive comparisons to never match. Replace with .astext which generates the ->> operator (unquoted text extraction), making issue lookups by title and identifier work correctly. --- .../app/services/linear/tool_metadata_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/surfsense_backend/app/services/linear/tool_metadata_service.py b/surfsense_backend/app/services/linear/tool_metadata_service.py index edaaa369d..05e49a84b 100644 --- a/surfsense_backend/app/services/linear/tool_metadata_service.py +++ b/surfsense_backend/app/services/linear/tool_metadata_service.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from sqlalchemy import String, and_, cast, func, or_ +from sqlalchemy import and_, func, or_ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.future import select @@ -296,11 +296,11 @@ class LinearToolMetadataService: SearchSourceConnector.user_id == user_id, or_( func.lower( - cast(Document.document_metadata["issue_title"], String) + Document.document_metadata["issue_title"].astext ) == ref_lower, func.lower( - cast(Document.document_metadata["issue_identifier"], String) + Document.document_metadata["issue_identifier"].astext ) == ref_lower, func.lower(Document.title) == ref_lower,