Repository navigation
fix(conversations): resolve exact IDs in search and chat - #11167
Conversation
Route canonical conversation UUIDs and h.omi.me share links through owner-scoped exact lookup while preserving semantic search for natural-language queries. Update the agent tool guidance and generated surfaces. Failure-Class: none
There was a problem hiding this comment.
6 issues found across 16 files
Confidence score: 3/5
- In
backend/utils/conversations/search.py, exact date searches with an inclusive end bound can miss conversations created in the final second because request and hydrated timestamps use different precision, which can produce false “no result” outcomes for users — normalize both sides to integer-second precision before comparison. - In
backend/utils/conversations/search.py, share URLs ending with a bare?or#are being treated as exact references, so valid free-text input can be routed down the wrong path and return unexpected results — require both delimiter presence and non-empty parsed query/fragment values. - In
backend/utils/retrieval/tools/conversation_tools.py, exact-reference lookup failures are reported as vector-search results, which can cause the agent to interpret a hard ID miss as partial semantic output — map this branch to an exact-reference-specific failure/exception path. backend/tests/unit/test_conversation_search_date_validation.pyandbackend/routers/conversations.pyboth have consistency risks: module-scope attribute reassignment can leak state across tests, and exact-reference requests on page >1 can returncurrent_pagegreater thantotal_pages, which may confuse clients — scope/restore patches per test and align pagination metadata in the exact-reference branch.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/changelog/unreleased/20260805-conversation-id-search.json">
<violation number="1" location="desktop/macos/changelog/unreleased/20260805-conversation-id-search.json:2">
P3: The changelog "change" sentence ends with a trailing period, but the repo changelog convention (AGENTS.md and changelog/README.md) requires the fragment sentence to have no trailing period. Drop the final period to match the documented format.</violation>
</file>
<file name="backend/utils/retrieval/tools/conversation_tools.py">
<violation number="1" location="backend/utils/retrieval/tools/conversation_tools.py:445">
P2: Exact-reference failures are reported as vector-search results even though this branch deliberately bypasses vector search, which can make the agent treat a failed ID lookup as partial search output. The exception path should report the active query mode and use an exact-lookup-specific failure message.</violation>
</file>
<file name="backend/tests/unit/test_conversation_search_date_validation.py">
<violation number="1" location="backend/tests/unit/test_conversation_search_date_validation.py:209">
P3: These three lines permanently reassign router module attributes at module scope and are never restored, so they silently change behavior for every test in this file (and any future test) rather than being scoped. In particular `conversation_matches_date_range` returning True forever and `clamp_conversation_search_pagination` returning (1,10) mean the new exact-reference path's date-range filter and pagination clamping are never genuinely verified by these tests — a regression there would pass silently. Scope these with `patch.object(conv, ...)` inside each exact-reference test (as the rest of this file does) and drop the module-level overrides, or restore the real helpers after use.</violation>
</file>
<file name="backend/utils/conversations/search.py">
<violation number="1" location="backend/utils/conversations/search.py:53">
P2: A share URL ending in a bare `?` or `#` is incorrectly treated as an exact reference instead of normal search text. Check for the delimiter's presence as well as nonempty parsed values so every query/fragment variant stays on the natural-language path.</violation>
<violation number="2" location="backend/utils/conversations/search.py:78">
P2: Exact searches with an inclusive end bound can incorrectly return no result for conversations created during the bound's final second. Normalize hydrated timestamps to the same integer-second precision as the request bounds and Typesense index in both the datetime and string branches.</violation>
</file>
<file name="backend/routers/conversations.py">
<violation number="1" location="backend/routers/conversations.py:1275">
P3: For an exact conversation reference requested on page >1, the branch clears `conversations` but still returns `current_page: exact_page` alongside `total_pages: 1`, so a client can observe current_page > total_pages with empty items. Since an exact match yields at most one result and only page 1 is meaningful, clamp the reported current page to 1 (or make total_pages consistent with the returned page) so pagination metadata stays self-consistent.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| conversation_ids = merge_conversation_search_ids(keyword_ids, vector_ids) | ||
| keyword_ids: List[str] = [] | ||
| vector_ids: List[str] = [] | ||
| if exact_conversation_id: |
There was a problem hiding this comment.
P2: Exact-reference failures are reported as vector-search results even though this branch deliberately bypasses vector search, which can make the agent treat a failed ID lookup as partial search output. The exception path should report the active query mode and use an exact-lookup-specific failure message.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/tools/conversation_tools.py, line 445:
<comment>Exact-reference failures are reported as vector-search results even though this branch deliberately bypasses vector search, which can make the agent treat a failed ID lookup as partial search output. The exception path should report the active query mode and use an exact-lookup-specific failure message.</comment>
<file context>
@@ -422,17 +440,25 @@ def search_conversations_tool(
- conversation_ids = merge_conversation_search_ids(keyword_ids, vector_ids)
+ keyword_ids: List[str] = []
+ vector_ids: List[str] = []
+ if exact_conversation_id:
+ conversation_ids = [exact_conversation_id]
+ else:
</file context>
| or parsed.query | ||
| or parsed.fragment |
There was a problem hiding this comment.
P2: A share URL ending in a bare ? or # is incorrectly treated as an exact reference instead of normal search text. Check for the delimiter's presence as well as nonempty parsed values so every query/fragment variant stays on the natural-language path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/conversations/search.py, line 53:
<comment>A share URL ending in a bare `?` or `#` is incorrectly treated as an exact reference instead of normal search text. Check for the delimiter's presence as well as nonempty parsed values so every query/fragment variant stays on the natural-language path.</comment>
<file context>
@@ -12,6 +14,84 @@ class ConversationSearchUnavailableError(Exception):
+ if (
+ parsed.scheme.lower() != 'https'
+ or parsed.netloc.lower() != _EXACT_CONVERSATION_HOST
+ or parsed.query
+ or parsed.fragment
+ or not parsed.path.startswith(_EXACT_CONVERSATION_PATH_PREFIX)
</file context>
| or parsed.query | |
| or parsed.fragment | |
| or '?' in value | |
| or '#' in value |
| if isinstance(created_at, datetime): | ||
| if created_at.tzinfo is None: | ||
| created_at = created_at.replace(tzinfo=timezone.utc) | ||
| timestamp = created_at.timestamp() |
There was a problem hiding this comment.
P2: Exact searches with an inclusive end bound can incorrectly return no result for conversations created during the bound's final second. Normalize hydrated timestamps to the same integer-second precision as the request bounds and Typesense index in both the datetime and string branches.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/conversations/search.py, line 78:
<comment>Exact searches with an inclusive end bound can incorrectly return no result for conversations created during the bound's final second. Normalize hydrated timestamps to the same integer-second precision as the request bounds and Typesense index in both the datetime and string branches.</comment>
<file context>
@@ -12,6 +14,84 @@ class ConversationSearchUnavailableError(Exception):
+ if isinstance(created_at, datetime):
+ if created_at.tzinfo is None:
+ created_at = created_at.replace(tzinfo=timezone.utc)
+ timestamp = created_at.timestamp()
+ elif isinstance(created_at, (int, float)):
+ timestamp = float(created_at)
</file context>
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "change": "Pasting a conversation ID or share link into search now opens the exact conversation." | |||
There was a problem hiding this comment.
P3: The changelog "change" sentence ends with a trailing period, but the repo changelog convention (AGENTS.md and changelog/README.md) requires the fragment sentence to have no trailing period. Drop the final period to match the documented format.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/changelog/unreleased/20260805-conversation-id-search.json, line 2:
<comment>The changelog "change" sentence ends with a trailing period, but the repo changelog convention (AGENTS.md and changelog/README.md) requires the fragment sentence to have no trailing period. Drop the final period to match the documented format.</comment>
<file context>
@@ -0,0 +1,3 @@
+{
+ "change": "Pasting a conversation ID or share link into search now opens the exact conversation."
+}
</file context>
| "change": "Pasting a conversation ID or share link into search now opens the exact conversation." | |
| "change": "Pasting a conversation ID or share link into search now opens the exact conversation" |
|
|
||
| # The router imports these helpers from a lightweight module stub in this test file. Keep the default | ||
| # parser on the natural-language path; individual exact-reference tests override it explicitly. | ||
| conv.parse_exact_conversation_reference = MagicMock(return_value=None) |
There was a problem hiding this comment.
P3: These three lines permanently reassign router module attributes at module scope and are never restored, so they silently change behavior for every test in this file (and any future test) rather than being scoped. In particular conversation_matches_date_range returning True forever and clamp_conversation_search_pagination returning (1,10) mean the new exact-reference path's date-range filter and pagination clamping are never genuinely verified by these tests — a regression there would pass silently. Scope these with patch.object(conv, ...) inside each exact-reference test (as the rest of this file does) and drop the module-level overrides, or restore the real helpers after use.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/unit/test_conversation_search_date_validation.py, line 209:
<comment>These three lines permanently reassign router module attributes at module scope and are never restored, so they silently change behavior for every test in this file (and any future test) rather than being scoped. In particular `conversation_matches_date_range` returning True forever and `clamp_conversation_search_pagination` returning (1,10) mean the new exact-reference path's date-range filter and pagination clamping are never genuinely verified by these tests — a regression there would pass silently. Scope these with `patch.object(conv, ...)` inside each exact-reference test (as the rest of this file does) and drop the module-level overrides, or restore the real helpers after use.</comment>
<file context>
@@ -204,6 +204,12 @@ class _MemorySystem(str, Enum):
+# The router imports these helpers from a lightweight module stub in this test file. Keep the default
+# parser on the natural-language path; individual exact-reference tests override it explicitly.
+conv.parse_exact_conversation_reference = MagicMock(return_value=None)
+conv.clamp_conversation_search_pagination = MagicMock(return_value=(1, 10))
+conv.conversation_matches_date_range = MagicMock(return_value=True)
</file context>
| if exact_page != 1: | ||
| conversations = [] |
There was a problem hiding this comment.
P3: For an exact conversation reference requested on page >1, the branch clears conversations but still returns current_page: exact_page alongside total_pages: 1, so a client can observe current_page > total_pages with empty items. Since an exact match yields at most one result and only page 1 is meaningful, clamp the reported current page to 1 (or make total_pages consistent with the returned page) so pagination metadata stays self-consistent.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/conversations.py, line 1275:
<comment>For an exact conversation reference requested on page >1, the branch clears `conversations` but still returns `current_page: exact_page` alongside `total_pages: 1`, so a client can observe current_page > total_pages with empty items. Since an exact match yields at most one result and only page 1 is meaningful, clamp the reported current page to 1 (or make total_pages consistent with the returned page) so pagination metadata stays self-consistent.</comment>
<file context>
@@ -1254,6 +1257,31 @@ def search_conversations_endpoint(
+ if conversation_matches_speaker(conversation, search_request.speaker_id)
+ and conversation_matches_date_range(conversation, start_timestamp, end_timestamp)
+ ]
+ if exact_page != 1:
+ conversations = []
+ redact_conversations_for_list(conversations)
</file context>
| if exact_page != 1: | |
| conversations = [] | |
| if exact_page != 1: | |
| conversations = [] | |
| exact_page = 1 |
Summary
https://h.omi.me/conversations/<uuid>share links through the existing owner-scoped lookup.User-facing behavior
Pasting the UUID copied from iOS, or the desktop share link, now finds the exact accessible conversation. Natural-language search is unchanged. Malformed, missing, foreign, or locked references return the existing generic no-result behavior.
The parser is deliberately strict: only a canonical UUID or an exact HTTPS
h.omi.meconversation URL is treated as an identifier. Partial IDs, lookalike hosts, extra URL components, and query/fragment variants remain normal search text.Scope
This fixes lookup behavior in the mobile search endpoint and Chat search tools. Desktop local identity reconciliation remains separate and is tracked by issue #9355.
Product invariants affected
Tests
make preflightpassed all 10 checks.Failure-Class: none