[MEDIUM] Decide createCoreFetch default responseShape ('full' vs 'body') and align README + call sites #5
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From audit #1.
Problem
src/core-fetch.ts:104defaultsresponseShapeto'full'but the README example shows'body'. Derived projects have been observed using both; the docs/code mismatch is a footgun.Remediation
Pick one default and align everything:
'body'and add a deprecation pass on the old'full'callers, OR'full'and update the README + every derived project's call site to passresponseShape: 'body'explicitly where they want the body shape.Acceptance
Effort: small (decision-driven).
Agent Evaluation
Note on the audit framing: The current shapes in
core-fetch.tsare'wrapped'and'body'(not'full'as the audit body says). Default in code is'wrapped'(line 104). Treating that as the issue: the docstring at the top of the file calls'wrapped'the default, the README example shows theresponseShape: 'body'form, and downstream usage is split:responseShape: 'body'explicitly (matches its orval config)'wrapped''wrapped'(no override)So the runtime split today is fewo-webapp on 'body', everyone else on 'wrapped'.
Feasibility: Trivial code change either direction. The friction is in downstream PRs if we flip the default.
Impact: Medium. The footgun is real — Orval's generator emits the body-shape mutator signature, so a consumer wiring
createCoreFetchwithout thinking gets the wrapped shape and their generated client misbehaves silently (the response object becomes{data, status, headers}where the generator expecteddata). ForgettingresponseShape: 'body'on a fresh project is exactly the kind of bug that doesn't surface until a deeply-nested response handler tries to read a property and getsundefined.Effort: Small (the change), Small-Medium (the downstream sweep).
Recommendation: Accept.
Implementation plan
src/core-fetch.ts— the??default on line 104 + the comment block on lines 4-9 + the README example.package.jsonversion to flag this as a behaviour change to downstreams (semver: minor if the new default doesn't break existing callers, major if it does).core-fetch.tsto either drop the now-redundantresponseShapearg or add it explicitly so the previous behaviour is preserved. One PR per repo.'X'— passresponseShape: 'Y'to get the other shape") to remove ambiguity.Decision needed
Check one (edit this comment):
'body'— matches Orval's generator expectation, makes the no-arg form correct out of the box, fewo-webapp's existing override becomes redundant. Palibu + webapp-template flip behaviour silently — needs explicit testing of their existing fetches.'wrapped'— backwards compatible for palibu + webapp-template; fewo-webapp'sresponseShape: 'body'override stays. Update README + docstring to make the default explicit so future projects don't trip over it. No silent behaviour flips downstream.Default recommendation: A. The whole point of the scaffold is that the no-arg form should be the right answer for the typical Orval-driven derived project. If
'wrapped'is the default, every new project hits the same footgun the audit identified.Evaluated webapp-scaffold#5 — Small/Medium, recommend accept; A/B decision on default (body vs wrapped). Note: shapes in code are wrapped/body, audit said full/body.
I choose Option A
Re-evaluation
Owner selected Option A — Default
'body'.Acknowledged. Implementation pass:
core-fetch.ts: change the default from'wrapped'to'body'(factory ctor arg + docstring + the inline default at the destructure).README.md+ top-of-file docstring: update the default-behaviour example so the no-arg form returns the body directly; mentionresponseShape: 'wrapped'for callers who want{response, body}.palibu: audit everycreateCoreFetch()call site; either add explicitresponseShape: 'wrapped'(preserve behaviour) or migrate consumers to expect plain body. PR alongside the scaffold bump.webapp-template: same — add explicitresponseShape: 'wrapped'if any view depends on the wrapped shape; otherwise migrate.fewo-webapp: drop the now-redundantresponseShape: 'body'override (separate PR after scaffold bump lands).Apply the
acceptedlabel to trigger implementation. The scaffold-side change is small; the downstream coordination is what makes this Medium effort.Re-evaluated #5 — owner picked Option A (default body); awaiting accepted label.
Implemented #5 → commit
fd451fd, version 0.4.0 (Option A: default flipped to 'body'; webapp-template doc aligned in cdbcd5a).