Skip to content

fix(rest): resource().delete runs the Endpoint class's process() - #4698

Merged
ntucker merged 7 commits into
masterfrom
claude/project-thread-fh3kfr
Nov 17, 2026
Merged

ntucker merged 7 commits into
masterfrom
claude/project-thread-fh3kfr

Conversation

@ntucker

@ntucker ntucker commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Bug. resource() gives delete its own process() (an empty body becomes the params), and that replaces the Endpoint class's process(). A base class that unwraps { data } or converts key case returned the raw body for delete only.

#4695 worked around this instead of fixing the root cause, and the workaround got past review. It moved app-wide reshaping to parseResponse() and added "not process(), because resource().delete sets its own" to network-transform, the axios/ky/got tables and the rest-setup skill. #4635 then built on that rule. Before #4695, the docs had always used process() for this, back to the 2018 camelCase example.

Separately, the "Name calling" example renamed an Entity's field in a base-class process() guarded by 'key' in value, so lists and nested Entities never got the rename.

Solution

  • resource().delete runs the resource's process option, or else the Endpoint class's process(), on a non-empty body. An empty body still becomes the params. Patch changeset delete-base-process.
  • Response reshaping goes back to process(). This undoes feat(codemods): Migrate more of v0.19 automatically; trim the migration skill #4695's workaround in network-transform ("Snakes to camels"), axios-migration (prose and the transformResponse row), ky/got hooks.afterResponse, and the rest-setup skill row from docs(rest): Show getPage and push with a { data, meta } envelope #4635.
  • Entity.process() for one Entity's fields. "Name calling" renames in Article.process() and maps back in getRequestInit(). The network-transform intro and the data-client-rest skill add Entity.process() beside endpoint process().
  • The resource docs' delete process snippet shows the call to the base.

Open questions

A base-class process() now runs on delete bodies, which it never saw before. One written for other endpoints' shapes could behave differently there. I treated this as a fix (patch) because the old behavior was the bug that #4695 documented around.

Assumptions and validation

  • New test delete runs the base class process() / resource process option in resource-construction.test.ts. It fails on master (2/2) and passes with the fix. The rest suites pass (159 tests) (high).
  • With type checking on, resource-construction.test.ts shows the same pre-existing sandbox errors as master and none from the new test (high).
  • yarn check:doc-examples react (285) and yarn build:skills pass (high).
  • I skipped the V8 check. The change adds one .call on delete responses only, which is not a hot path (medium).

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv


Note

Medium Risk
DELETE invalidation keys can change when base process() runs on delete bodies, which may affect cache invalidation for apps that relied on the old raw-body behavior.

Overview
resource().delete now pipes non-empty DELETE response bodies through the resource's process option or the Endpoint class's process() before resolving the invalidation key. Empty responses (204) and bodies that process() empties still fall back to URL params, matching other endpoints.

Docs and agent skills are updated to restore process() as the recommended hook for envelope unwrap, key-case transforms, and axios/got/ky migration—reverting guidance that steered those transforms to parseResponse() because delete used to skip base process().

Network-transform docs now recommend Entity.process() for per-entity field renames (including lists/nested data), with an updated Article example. A regression test covers delete with both base-class and resource-level process().

Reviewed by Cursor Bugbot for commit 4e2d1f2. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T16:30:48.499238Z 4e2d1f2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e2d1f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@data-client/rest Patch
example-benchmark-react Patch
test-bundlesize Patch
coinbase-lite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview: https://docs-site-pr-4698-data-client.vercel.app

Built from 4e2d1f2 merged into master (this build). Locales: en (the merge queue builds every locale).

…ow by layer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv
…one Entity's fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv
@ntucker ntucker changed the title docs: Recommend RestEndpoint.process() only for one endpoint's result docs: Rename an Entity's fields in Entity.process() Nov 17, 2026

ntucker commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Staff engineer (Cursor agent): FOLLOW_UP (not blocking this PR) at 3fcaa95.

This push brings back master's unscoped wording: "Shape of the parsed data → process()" in data-client-rest/SKILL.md, "process() for responses" in the network-transform intro, and interceptors.response → parseResponse() / process() in the axios tables. Against master, that's no regression. But it still conflicts with data-client-rest-setup/SKILL.md ("process() would miss resource().delete") and with network-transform's own camelCase section.

What I ran: I used published @data-client/rest@0.18.2, whose delete block matches the branch's resource.ts. I built resource({ Endpoint: Base }) with a Base.process that unwraps .data and mocked the fetch body {data:{...},meta:{}}. Get, getList, push, unshift, update and partialUpdate all used the base process. delete and delete.extend() returned the raw envelope, because resource() passes its own process and Endpoint uses Object.assigns it as an own property. Putting the unwrap in parseResponse worked for delete.

What this means for agents: an agent that follows the skill row and puts an every-response unwrap or key-case change in a base-class process() gets a silent bug on delete only.

Suggested follow-up after merge: scope the table row to "One endpoint's result → process()" and add "Every response (unwrap, key case) → parseResponse() on a base class". Do the same in the intro sentence and the axios interceptors.response cells. This is the wording the PR had at ba0366b/50479bc0. If you'd rather fold it in here, it's a small table edit.

delete set its own process(), which replaced the base class's, so #4695
moved app-wide reshaping to parseResponse() as a workaround. Fix the root
cause and route response reshaping back to process() in docs and skills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv
@ntucker ntucker changed the title docs: Rename an Entity's fields in Entity.process() fix(rest): resource().delete runs the Endpoint class's process() Nov 17, 2026

ntucker commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Staff engineer (Cursor agent): FOLLOW_UP at e431b59. No change needed in this PR.

This resolves my earlier follow-up the right way. Before, docs routed around the gap where resource().delete's own process() replaced the base class's. Now delete calls baseProcess (the resource's process option, else Endpoint.prototype.process) for any non-empty body. That fixes the cause, so the parseResponse-vs-process caveat can come out of the guide, the skills and the axios table. The extra code is small, and docs and skills get simpler.

What I checked (by reading only; I didn't run anything at this SHA): baseProcess.call(this, …) keeps this. The empty-body check runs first, so a base like the test's value.data (no ?.) never sees a 204 null. .extend({ process }) on delete still replaces the whole method. The new it.each covers both sources (base class and resource option) and both outcomes (200 envelope, 204 → params).

Note for after merge (not tested): the empty check runs on the raw body only. So when an envelope API returns { "data": null } or { "data": {} } on delete, the unwrapped result is null/{} instead of falling back to params. Before this PR, delete returned the raw envelope, so it's no regression. It's still the one envelope case the new behavior misses. To fix it, also check the processed value: const v = baseProcess.call(this, res, params); return v && Object.keys(v).length ? v : params;, keeping the raw check first. Only worth doing if a real API shows up with that shape.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 97.5 kB

ℹ️ View Unchanged
Filename Size Change
examples/test-bundlesize/dist/App.js 1.25 kB 0 B
examples/test-bundlesize/dist/polyfill.js 244 B 0 B
examples/test-bundlesize/dist/rdcClient.js 9.62 kB 0 B
examples/test-bundlesize/dist/rdcEndpoint.js 7.47 kB +7 B (+0.09%)
examples/test-bundlesize/dist/rdcNextjs.js 11.2 kB 0 B
examples/test-bundlesize/dist/rdcPipeableStream.js 8.65 kB 0 B
examples/test-bundlesize/dist/react.js 58.5 kB 0 B
examples/test-bundlesize/dist/webpack-runtime.js 577 B 0 B

compressed-size-action

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (881814e) to head (4e2d1f2).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4698   +/-   ##
=======================================
  Coverage   98.63%   98.64%           
=======================================
  Files         163      163           
  Lines        3161     3164    +3     
  Branches      627      629    +2     
=======================================
+ Hits         3118     3121    +3     
  Misses          9        9           
  Partials       34       34           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e431b59. Configure here.

Comment thread packages/rest/src/resource.ts Resolved
…y; drop extra const

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e2d1f24b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +152 to +156
(extraMutateOptions.process || Endpoint.prototype.process).call(
this,
res,
params,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Await asynchronous processing before checking for an empty result

When the base class or resource option supplies an asynchronous process(), this call assigns its Promise to res, and the subsequent Object.keys(res).length check treats that Promise as empty. Consequently, DELETE resolves to the URL params instead of the processed response, and a rejected processor becomes an unhandled rejection rather than a failed request. Other endpoints support asynchronous processors because RestEndpoint returns their result from its .then() callback. Await the processor's result before applying the empty-result fallback so DELETE preserves that behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving this as is. process() is synchronous by contract: RestEndpoint's type is process(value, ...args): ResolveType<F>, not a Promise, and no doc or example uses an async process(). Async work belongs in parseResponse(), which is awaited. An async process() on other endpoints only works because .then() happens to flatten it, and its type is already wrong. Supporting it here would mean awaiting inside delete for an untyped case and would add bundle size.


Generated by Claude Code

@ntucker
ntucker added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit fa8d03b Nov 17, 2026
39 checks passed
@ntucker
ntucker deleted the claude/project-thread-fh3kfr branch November 17, 2026 16:35

This branch was successfully deployed

1 active deployment
docs-preview — 4e2d1f24 Deployed Nov 17, 2026 by ntucker via preview / docs deploy #6231
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.

2 participants