Skip to content

Fix Resource post/put/patch data type + document search sort + content-type table#495

Draft
kriszyp wants to merge 1 commit into
mainfrom
kris/clarify-resource-post-data-type
Draft

Fix Resource post/put/patch data type + document search sort + content-type table#495
kriszyp wants to merge 1 commit into
mainfrom
kris/clarify-resource-post-data-type

Conversation

@kriszyp
Copy link
Copy Markdown
Member

@kriszyp kriszyp commented May 25, 2026

Summary

Three corrections / clarifications to reference/resources/resource-api.md based on real friction I hit while building harper-celebrity-match and harper-roadmap demos.

1. post / put / patch data type is wrong

The page documents the signature as data: Promise<object> and the example shows let data = await promisedData;. That's not what the runtime actually passes. In server/REST.ts request.data is assigned the synchronous return value of the deserializer — for application/json requests that's the parsed value, not a Promise.

Result: every user initially writes const data = await promisedData, sees it work because await of a non-thenable just resolves to itself, then copy-pastes that into other handlers. Eventually they find Search.js / Import.js in our example components doing const { foo } = data and rewrite — the docs should match the example.

Fixed signature: data: object. Example updated to drop the await.

2. Content-type → data-shape table

Added a small table explaining what data is for the built-in deserializers (JSON, CBOR, MessagePack, NDJSON, plain text).

3. sort requires a matching indexed condition

The current sort docs imply sort: { attribute: 'id' } should just work because id is the primary key. It doesn't — Harper's query planner requires the sort attribute to be both @indexed AND narrowed by a conditions entry. The error message you get is "id is not indexed and not combined with any other conditions" which is misleading (id IS indexed). Documented the actual requirement + the workaround.

Tracks:

🤖 Generated with Claude Code

…tent-type behaviour

* `data` parameter on `post` / `put` / `patch` is the deserialized
  request body, not a `Promise<object>` — the example showing
  `let data = await promisedData;` is misleading because the
  deserializer returns synchronously for every built-in content type.
  Update the signatures and the example.
* Add a content-type → `data`-shape table so users know what to expect
  on non-JSON requests.
* Document the indexed-attribute + matching-condition requirement for
  `sort` and give the workaround that returned the only error message
  users see today: "X is not indexed and not combined with any other
  conditions".

Tracks harper #774 (long-fetch abort docs) and #773 (sort error).
@github-actions
Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-495

This preview will update automatically when you push new commits.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant