Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…n aggregate() Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/e3d0d80a-c390-42e4-bd21-38d21ba233a6 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix charts rendering blank due to response extraction logic
fix(data-objectstack): charts blank due to missing Apr 1, 2026
rows envelope handling in aggregate()
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes blank chart rendering by updating @object-ui/data-objectstack’s aggregate() response parsing to correctly extract analytics rows from the API’s { rows } / { data: { rows } } envelopes, and adds unit tests to prevent regressions.
Changes:
- Extend
aggregate()’srawRowsextraction to handle{ rows: [...] }and{ data: { rows: [...] } }response shapes. - Add two unit tests covering both envelope variants and confirming measure-key remapping (e.g.
expected_revenue_sum→expected_revenue). - Update the changelog entry to document the follow-up fix for blank charts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/data-objectstack/src/index.ts | Adds data.rows / data.data.rows handling so analytics query results don’t incorrectly fall through to []. |
| packages/data-objectstack/src/aggregate.test.ts | Adds test coverage for both analytics response envelopes and validates measure-key remapping still works. |
| CHANGELOG.md | Documents the additional envelope-handling fix as part of the analytics aggregate entry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
rawRowsextraction chain inaggregate()never checked fordata.rowsordata.data.rows, so it always fell through to[]. The analytics API (/api/v1/analytics/query) returns{ rows, fields, sql }— either directly (SDK unwraps the outer envelope) or nested underdata— neither of which was handled.Changes
packages/data-objectstack/src/index.ts— ExtendrawRowschain withdata.rowsanddata.data.rowschecks:packages/data-objectstack/src/aggregate.test.ts— Two new test cases covering both response shapes ({ rows }and{ data: { rows } }), including verification that measure keys (e.g.expected_revenue_sum) are correctly remapped to field names (expected_revenue).CHANGELOG.md— Updated analytics entry to note this follow-up fix.Original prompt
Problem
Issue #1160 was partially fixed — the
aggregate()method inpackages/data-objectstack/src/index.tsnow correctly sendsmeasuresas a string array (e.g.['expected_revenue_sum']), so the backend no longer throwst.split is not a function. However, charts still render blank because the response extraction logic does not handle the actual response shape returned by the analytics API.Actual API Response
The analytics API (
/api/v1/analytics/query) returns data in this envelope:{ "success": true, "data": { "rows": [ { "stage": "closed_won", "expected_revenue_sum": 225000 }, { "stage": "negotiation", "expected_revenue_sum": 36000 }, { "stage": "proposal", "expected_revenue_sum": 51000 }, { "stage": "prospecting", "expected_revenue_sum": 50000 }, { "stage": "qualification", "expected_revenue_sum": 14000 }, { "stage": "closed_lost", "expected_revenue_sum": 0 } ], "fields": [ { "name": "stage", "type": "string" }, { "name": "expected_revenue_sum", "type": "number" } ], "sql": "..." } }The
@objectstack/clientSDK'sanalytics.query()method likely unwraps the{ success, data }outer envelope, returning{ rows: [...], fields: [...], sql: "..." }to the caller.Current Extraction Logic (Broken)
In
packages/data-objectstack/src/index.ts, lines 851-854:The chain never checks for
data.rows, which is the actual property containing the row data. This meansrawRowsis always[], so the chart receives empty data and renders blank.If the SDK does NOT unwrap the outer envelope, then the shape would be
{ success: true, data: { rows: [...] } }, and the chain checksdata.datawhich is{ rows, fields, sql }— also not an array, so it still falls through to[].Required Fix
Update the
rawRowsextraction chain in theaggregate()method to handle all known response shapes, including therowsproperty:Files to Modify
packages/data-objectstack/src/index.ts— Fix therawRowsextraction inaggregate()method (around line 851)packages/data-objectstack/src/aggregate.test.ts— Add test cases for therowsresponse envelope:analytics.query()returns{ rows: [...] }(SDK unwraps outer envelope)analytics.query()returns{ data: { rows: [...] } }(SDK does not unwrap)CHANGELOG.md— Update the existing analytics entry to note the additional fix for therowsresponse envelopeAcceptance Criteria
{ success: true, data: { rows: [...], fields: [...] } }, charts should receive the correct data arraydata,results, and direct array responses must continue to passrowsanddata.rowsenvelope patternsexpected_revenue_sum→expected_revenue) must still work correctly after extractionThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: 评估当前任务的进展,目前接口不报错了,但是前端图表显示为空白。参考以下接口输入:{"cube":"opportunity","measures":["expected_revenue_sum"],"dimensions":["stage"]}
返回 : {
"success": true,
"data": {
"rows": [
{
"stage": "closed_won",
"expected_revenue_sum": 225000
},
{
"stage": "negotiation",
"expected_revenue_sum": 36000
},
{
"stage": "proposal",
"expected_revenue_sum": 51000
},
{
"stage": "prospecting",
"expected_revenue_sum": 50000
},
{
"stage": "qualification",
"expected_revenue_sum": 14000
},
{
"stage": "closed_lost",
"expected_revenue_sum": 0
}
],
"fields": [
{
"name": "stage",
"type": "string"
},
{
"name": "expected_revenue_sum",
"type": "number"
}
],
"...
This pull request was created from Copilot chat.