Release: profile query hotfix and identify docs#537
Conversation
ClickHouse substitutes select aliases into GROUP BY and WHERE expressions, so aliasing max(profile_id) as profile_id made the visitor-key expression an illegal aggregation and broke profile_list in production; internal aliases are now latest_profile_id with the external field name preserved.
quick start as per-platform tabs, tightened sections, and an Identify Users entry in the hand-maintained sidebar tree, which meta.json does not feed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Unkey Deploy
|
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Client as Frontend Client
participant SDK as Browser SDK
participant API as API Server
participant Builder as ProfilesBuilder
participant CH as ClickHouse
participant DB as Profile Store
Note over Client,DB: Identify Flow (precondition for profile data)
Client->>SDK: identify(userId, traits)
SDK->>API: POST /identify { profileId, traits }
API->>DB: Store profile mapping
DB-->>API: OK
API-->>SDK: 200
SDK-->>Client: Profile linked
Note over Client,CH: Profile List Query
Client->>API: GET /profiles (list/detail)
API->>Builder: getProfiles()
Builder->>Builder: Build SQL with CTE `visitor_profiles`
Note over Builder: CHANGED: Internal alias renamed to `latest_profile_id`<br/>to avoid ClickHouse alias substitution in GROUP BY/WHERE
Builder->>CH: SELECT ... max(profile_id) as latest_profile_id ...
alt No alias conflict (fixed)
CH->>CH: Execute query, GROUP BY visitor_id using `latest_profile_id` column name (not `profile_id`)
CH-->>Builder: Result with column `latest_profile_id`
else Previous alias `profile_id` would be substituted
Note over CH: Would cause "Illegal aggregation" error
end
Builder->>Builder: Outer SELECT: `latest_profile_id` AS `profile_id`
Builder-->>API: Result set with `profile_id` field
API-->>Client: JSON response { profile_id: ..., ... }
Shadow auto-approve: would require human review. Code fix in profile query builder renames an internal alias, altering SQL logic. Though small, it could impact profile queries and requires human review.
Re-trigger cubic
Fixes profile_list/profile_detail failing in production: ClickHouse substitutes select aliases into GROUP BY and WHERE expressions, so the max(profile_id) alias made the visitor-key expression an illegal aggregation. Internal aliases renamed; external fields unchanged.
Also reworks the Identify Users docs page and adds it to the sidebar.
Summary by cubic
Fixes a production error in profile queries by renaming a shadowed aggregate alias that ClickHouse was substituting into GROUP BY/WHERE. Also updates the Identify Users docs and adds it to the sidebar.
Bug Fixes
latest_profile_idto avoid ClickHouse alias substitution errors.profile_idto keep the API response unchanged.New Features
Written for commit 5ddc363. Summary will update on new commits.