Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(hogql): request utf-16 validation positions (#101577)

Paweł Szczur95e71f9c0e4e
diff --git a/posthog/hogql/language_service.py b/posthog/hogql/language_service.py
index 36fc6e57728e..d92b8557e40a 100644
--- a/posthog/hogql/language_service.py
+++ b/posthog/hogql/language_service.py
@@ -288,7 +288,15 @@ class LanguageServiceClient:
)
def validate(self, team_id: int, user_id: int, query: str) -> LanguageServiceResult:
- return self._request("POST", team_id, user_id, "validate", "validate", {"query": query}, 1)
+ return self._request(
+ "POST",
+ team_id,
+ user_id,
+ "validate",
+ "validate",
+ {"query": query, "positionEncoding": "utf-16"},
+ 1,
+ )
def _request(
self,
diff --git a/posthog/hogql/test/test_language_service.py b/posthog/hogql/test/test_language_service.py
index a6ad08c0138d..8fc9af715a90 100644
--- a/posthog/hogql/test/test_language_service.py
+++ b/posthog/hogql/test/test_language_service.py
@@ -45,7 +45,7 @@ class TestLanguageServiceClient(SimpleTestCase):
request.assert_called_once()
call = request.call_args
assert call.args == ("POST", "http://language-service:8091/teams/12/users/34/validate")
- assert call.kwargs["json"] == {"query": "SELECT 1"}
+ assert call.kwargs["json"] == {"query": "SELECT 1", "positionEncoding": "utf-16"}
assert call.kwargs["timeout"] == (0.25, 1)
assert call.kwargs["headers"]["X-HogQL-Affinity-Key"] == (
"a5c8d54c25064f11498a937f38591eba85a3e67cccc102e6c4f76bbf5377cc37"