Skip to content

fix(entities): options objects return arrays again; cursor pages move to page() - #293

Open
arosenan wants to merge 1 commit into
mainfrom
fix/list-object-args-return-arrays
Open

arosenan wants to merge 1 commit into
mainfrom
fix/list-object-args-return-arrays

Conversation

@arosenan

Copy link
Copy Markdown
Contributor

Summary

SDK 0.8.49 routes any object argument of list() / filter() to /v2/list and returns { items, next_cursor, has_more }. The builder has written object-argument calls for months and expects an array, so on 0.8.49 those calls break (.map / .forEach / .length on a page object).

How common: builder-written code containing an entity list({...}) call, per month since March 2026: 2,000–4,300 apps. filter(query, {...}): 900–2,400 apps a month since June. Examples: list({}, 5), list({ limit: 5000 }), list({ filter, sort }), filter(q, { sort, limit }). One prod app looped at ~180 requests/min after its Task.list({ filter, sort }) started returning a page.

Under 0.8.48 those calls were already wrong except list({}): the object went out as sort[limit]=10 and the server turned it into a filter on a field that does not exist, returning [] (prod trace: result_count: 0).

Change

Call 0.8.49 This PR
list({ sort, limit, skip, fields }) page array, keys honoured
list({ filter: {...}, sort }) page array, filter applied
list({}, 5) page array, limit 5
list({ email }, '-created_date', 100) page array, filtered by email
filter(q, { sort, limit }) page array, keys honoured
list/filter with cursor or distinct page page (kept; overload deprecated)
new page({ query, sort, limit, fields, cursor }) — page
new page({ query, distinct, cursor }) — page of values

page() is the explicit cursor API, so an options object can never silently change the return shape again.

Rollout coupling

The apper builder prompt behind entity-sdk-v2-prompt teaches filter(q, { sort, limit }) as a page call. After this release that returns an array, so the prompt, the exec_tool corrective hint (flag-on example) and sdk_min_version need to move to page() in the same step. Keep the flag at its current audience until that apper change is live.

Testing

npm test (type tests + unit): 329 passed. npm run lint and npm run build clean. New tests cover page() for records, continuation and distinct; the object forms returning arrays with keys honoured; list({}, 5) and list({ email }, sort, limit); and the kept cursor/distinct compatibility.

🤖 Generated with Claude Code

… again; cursor pages move to page()

0.8.49 sent any object argument to /v2/list and returned { items, next_cursor, has_more }.
Builder-generated code has long called list({}), list({}, 5), list({ limit }),
list({ filter, sort }) and filter(query, { sort, limit }) and expects an array, so on
0.8.49 `.map`/`.length` break on those calls.

Now:
- list(options) / filter(query, options) return an array from the list route and honour
  sort, limit, skip and fields; list() also reads a filter (or query) key.
- An object with none of those keys is list()'s filter query: list({}, 5) keeps limit 5,
  and list({ email }, '-created_date', 100) follows filter()'s order.
- New page({ query, sort, limit, fields, cursor }) and page({ query, distinct, cursor })
  read one cursor page.
- An object carrying cursor or distinct still returns a page from list()/filter(), so code
  written for 0.8.49 keeps working; those overloads are deprecated in favour of page().

Under 0.8.48 the same object calls silently returned [] (the keys became filters on
fields that do not exist), so honouring the keys fixes that as well.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.51-pr.293.e71320c

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.51-pr.293.e71320c"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.51-pr.293.e71320c"
  }
}

Preview published to npm registry — try new features instantly!

@github-actions github-actions Bot added the docs-draft PR has auto-drafted documentation suggestions label Sep 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-draft PR has auto-drafted documentation suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant