Stop the sparse todolist PUT from erasing the description
Closes #545. First recordable of #374's rollout.
PUT /{accountId}/todolists/{id} is a full replace, omission clears, and every SDK shipped a sparse update against it — so renaming a list erased its description. This lands the merge-safe update / read-modify-write edit / verbatim replace triad in all six SDKs, modelled on the Todos surface from #372.
It also fixes a separate, silent data-loss bug in the Swift SDK, described next because it is independently important and will otherwise be hard to find later.
Also fixed: Swift's todolists.get() returned an empty value and reported success
This shipped to users and is unrelated to the triad — it was found while building it, and is called out here so a future bisect lands on this PR.
GET /{accountId}/todolists/{id} is modelled as the TodolistOrGroup union, which Swift emitted as a struct of two optional arms:
public struct TodolistOrGroup: Codable, Sendable {
public var todolist: Todolist?
public var group: TodolistGroup?
}
BC3 does not answer this route with a {"todolist": …} envelope. It answers with the recordable's flat JSON. Swift's synthesised Codable looked for the two envelope keys, found neither, set both arms to nil, and threw nothing.
So every Swift caller of client.todolists.get(id:) received a TodolistOrGroup with todolist == nil and group == nil, and no error to indicate anything had gone wrong. There was no way to read a todolist's name, description, or anything else through that method. Any code branching on the arms silently took the empty path.
Nothing caught it because the only two Swift tests touching the method fed the decoder an empty dictionary ([:]) and asserted hook identities, never the decoded value. Both now carry a full, realistic wire body.
The fix is in the generator, not the generated file: swift/Sources/BasecampGenerator/ModelEmitter.swift. TodolistOrGroup is the only union in the spec, so the blast radius is exactly this type.
This independently confirms the failure #544 predicted — that issue already stated "Swift's generated TodolistOrGroup expects wrapper keys and silently decodes two nil members from the flat response." It was right. Go had bypassed the union by hand long ago with a comment saying the same thing; TypeScript's type was a lie that happened to work at runtime; Kotlin returns JsonElement and sidestepped it. Swift was the one that actually broke.
Red proof, against pristine origin/main:
XCTAssertNotNil failed - pristine TodolistOrGroup decoded a FLAT todolist body into
todolist=nil group=nil and threw nothing
It took three layers to actually fix, and the chain is the useful part
Anyone touching the next oneOf should see how this went, because each layer looked correct and the next one was only found by attacking it:
Layer 1 — the original bug. Synthesised Codable looked for envelope keys, found none, set both arms nil, threw nothing.
Layer 2 — the first fix reintroduced the same shape one level up. Decoding the flat body into "the first arm that matches" meant try? on arm 1 and falling through to arm 2. But TodolistGroup's property set is a strict subset of Todolist's — zero exclusive keys, and description_attachments is required on Todolist alone. So a body that genuinely is a todolist but carries one malformed todolist-only field fails arm 1 and then decodes cleanly as a group, which simply ignores the bad key. The caller gets a successful .group with the description silently discarded: swallow-and-report-success, exactly the shape being fixed, one layer up. Caught by Codex on its second pass.
The fix: the emitter resolves each arm's $ref at generation time and gates a later arm on the body carrying none of the keys exclusive to earlier arms. Since TodolistGroup has zero exclusive keys, the group arm is unreachable on fallback and arm 1's real error propagates. The final guard now rethrows the first arm's error rather than inventing a generic one.
Red proof against layer 1's fix — the malformed body decoding cleanly as a fully-populated group, description gone:
failed - expected the todolist arm's decoding error to surface, got todolist=nil
group=Optional(Basecamp.TodolistGroup(appUrl: "...", ..., name: "Hardware", ...))
Layer 3 — that guard was itself almost entirely inert. BaseService.decoder sets .convertFromSnakeCase, so allKeys reach the guard already camelCased, while the emitter was writing snake_case literals. The guard fired only because description is a single word that survives conversion unchanged; the other eight spellings never matched. It passed its own test for the wrong reason. Found by testing the test, not by review.
The emitter now emits both spellings. testUnionMaskingGuardMatchesMultiWordKeys removes the single-word key so only multi-word ones can match, and was proved non-vacuous by reverting to the wire-only set and watching the group arm absorb the malformed todolist again:
failed - the group arm must not absorb a todolist carrying groups_url, got
group=Optional(Basecamp.TodolistGroup(...))
Layer 4 — the same coercion trap, one service over, and this one reached the wire. Kotlin's composite read its writable fields with (this[key] as? JsonPrimitive)?.contentOrNull ?: "". A JSON number or boolean renders as text; an array or object is not a JsonPrimitive at all and collapses to "". putFields then sends that value in the full-replace PUT — so a name-only update, or an edit that never touches description, silently overwrites or erases it. Unlike layers 1–3 this does not merely swallow an error and report success; it propagates the damage to the server, in the one method whose entire purpose is not losing data. Caught by Codex on its third pass.
The read now requires an actual JSON string and throws before the PUT; absent and explicit-null stay genuinely empty. Red proof against the unfixed helper — the PUT was still issued:
TodolistsServiceTest[jvm] > updateRefusesAMalformedDescriptionBeforeWriting()[jvm] FAILED
org.opentest4j.AssertionFailedError: expected a malformed description ([]) to abort the update
TodolistsServiceTest[jvm] > editRefusesAMalformedNameBeforeWriting()[jvm] FAILED
org.opentest4j.AssertionFailedError: expected a malformed name to abort the edit
Layer 5 — the same coercion, in the two languages I had just identified as unprotected. Codex's fourth pass found it in this PR's new Python and Ruby composites: a falsey non-string description read through or "" / || "" becomes "", and a truthy non-string rides through verbatim. Python erases on False, 0, [], {}; Ruby on false. Same full-replace PUT, same silent overwrite.
Fixed here rather than deferred, because these files are new code this PR introduces — shipping them as written would have added fresh instances of the defect one commit after documenting it. Both now treat absent/null as genuinely empty, require an actual string otherwise, and raise before any PUT. Red proofs asserted the raise and that only a GET was recorded, so a guard that fired after the PUT would still fail:
E Failed: DID NOT RAISE <class 'basecamp.errors.ApiError'> (13 failed, 2 passed)
Basecamp::ApiError expected but nothing was raised. (9 runs, 9 failures)
Seven defects, seven passes, one root cause
Six consecutive Codex passes each found a real defect, and an independent adversarial review of the delta Codex never saw found a seventh. The first five all landed in the read-modify-write path, in whichever language lacked a runtime decoder at that layer; the sixth was the error taxonomy of the guard added for the fifth:
| Pass | Defect | Language | Why there |
|---|---|---|---|
| 1 | Envelope decode → two nil arms, no error | Swift | oneOf response, synthesised Codable |
| 2 | Narrower arm masks the wider arm's real error | Swift | TodolistGroup ⊂ Todolist |
| 3 | contentOrNull coerces into the replace PUT | Kotlin | oneOf ⇒ untyped JsonElement |
| 4 | or "" / || "" coerces into the replace PUT | Python, Ruby | no typed layer at all |
| 5 | ?? "" forwards a wrong type into the replace PUT | TypeScript | types erased at build time |
| 6 | Malformed response field raised as caller misuse | TypeScript | error taxonomy, not coercion |
Pass 6 is a different kind of defect from the first five. It is not the coercion class: the guard added in pass 5 threw Errors.usage, giving code usage, when the malformed value had arrived in a successful API response — nothing the caller passed was at fault. The correct code is api_error, which TypeScript's other malformed-2xx paths already use. The same underlying confusion though: a value that came off the wire was treated as if it came from the caller.
The Python, Ruby, Kotlin and Swift guards added in this branch already drew that line correctly — ApiError/BasecampException.Api for the malformed response field, UsageError/Usage for the empty name, which genuinely is caller misuse since BC3 presence-validates name. Go uses wrapped parse errors for decode and reserves ErrUsage for caller misuse. TypeScript was the only outlier.
The 16 tests from pass 5 could not have caught it. They asserted the message text and the request sequence, and a wrong error code satisfies both — the vacuous-assertion shape where the assertion does not name the thing that can be wrong. They now pin all four: BasecampError instance, code === "api_error", the offending field in the message, and a request log of exactly ["GET"]. Reverting the fix while keeping the tightened tests fails all 16 on the code alone:
AssertionError: expected 'usage' to be 'api_error' // Object.is equality
Tests 16 failed | 2 passed | 22 skipped (40)
| 7 | Required name absent/null → "" written over the real name | all six | shared "absent means empty" branch |
Pass 7 came from an independent adversarial review of the delta nobody had seen, and it is the only instance in this family that corrupted data on the wire. name is @required and non-nullable and BC3 presence-validates it, so an absent-or-null name in a response is malformed — precisely what the guards exist to reject. The shared early return substituted "" instead, and on the edit path a callback deriving from the current name PUT that empty name over the real one, successfully and silently. Six of the seven prior instances misclassified or swallowed; this one wrote.
The fix is the rule, not the instance: classify by origin, not by value. The read step owns response provenance, the write step owns caller provenance, and each classifies only what it can see. A required field must arrive as a non-empty string — absent, null and "" are all malformed responses — while a caller-supplied empty name stays a usage error. Encoded that way in all six SDKs and in SPEC §6, so the next composite inherits the rule rather than rediscovering it.
Same review, same batch:
- Message truncation. The TypeScript site embedded the whole malformed value via
JSON.stringifywith no cap — measured at 408,929 characters against SPEC §9's 500-unit limit, and the only hand-written TS error site skipping the helper every sibling uses. unwrapTodolist's group-envelope branch invented an empty description, which on a full-replace endpoint erases the real one — an eighth live instance of the same erasure. It now refuses the projection, as Swift's unwrapper already did.- TypeScript now owns the caller-emptied name instead of inheriting
validationfrom the generatedreplace()— a third code for a condition the other four call a usage error. The generated error still governs directreplace()callers, where the name really is theirs. - Ruby's malformed-field error carries a hint, like its siblings.
Two existing tests were themselves the bug and had to be corrected, which is the sharpest warning in this PR: Ruby's nameless-todolist test demanded UsageError for a response the caller never touched, and a TypeScript test pinned validation for the composite path. Both passed, both encoded the defect, and both would have blocked the fix.
The invariant matrix — closed by sweep, not by round
Every one of the eight review passes found the same rule unapplied in whichever language had not been swept yet. The coercion guard, the taxonomy, the caller-provenance check, the statusless api_error, the truncation cap — each was correct where it was written and missing elsewhere. Converging language-by-language was the mistake; the fix is to close it by invariant.
Every cell below was filled by reading the code, not by assuming symmetry. "n/a" always carries its reason.
| Invariant | Go | TypeScript | Python | Ruby | Kotlin | Swift |
|---|---|---|---|---|---|---|
| Wrong-typed response value → API error, before any write | n/a — json.Unmarshal into a typed struct rejects it | yes | yes | yes | yes | yes — decode rejects it, now wrapped as the §6 shape |
| Required response field absent/null/empty → API error | yes | yes | yes | yes | yes | yes — Codable rejects absent/null; empty checked explicitly |
Wrong-typed caller value via edit → usage error | n/a — TodolistFields fields are string | yes — annotation erased at build time, so checked | yes | yes | n/a — compiler-enforced | n/a — compiler-enforced |
| Empty required caller field → usage error | yes | yes | yes | yes | yes | yes |
| API error is statusless and non-retryable (§6) | yes — *Error{Code: CodeAPI} | yes | yes | yes | yes — httpStatus: Int?, no placeholder | yes |
| Message capped at the §9 limit via the SDK's own helper | n/a — no value embedded, only the record id | truncateErrorMessage | _security.truncate | Security.truncate | truncateMessage | BasecampError.truncate |
| Offending field named in the message | yes | yes | yes | yes | yes | yes |
No write issued when any fires (["GET"] only) | yes | yes | yes | yes | yes | yes |
| Malformed envelope (scalar/array/null body) → API error | n/a — json.Unmarshal into a struct rejects it | yes | yes | yes | yes | yes — via the wrapped decode failure |
| Present envelope arm is a non-null object | n/a — decoder | yes | yes | yes | n/a — decoder | n/a — decoder |
| The error path itself never throws while rendering a value | n/a — no value embedded | yes — JSON.stringify can raise on a circular structure | yes — repr is user code and can raise | yes — inspect is user code and can raise | n/a — JsonElement is a closed JSON tree; rendering runs no user code | n/a — no value embedded |
The three "compiler-enforced" cells on the caller row are the same typed-decoder line that sorted every finding in this family: Go, Kotlin and Swift cannot express the wrong type at that boundary, so a runtime check would be unreachable code. TypeScript can, because its annotation is erased — which is why it is checked there and not grouped with them.
The path is now a closed enumeration, not an open-ended sweep
The route from wire to written value has exactly three levels, and each is guarded:
- the response body is an object — a scalar, array or null body (row 9)
- the selected envelope arm is a non-null object —
{"todolist": null}passed the outer check and was dereferenced into a nativeTypeError(row 11, pass 10) - each writable field is a string — the original coercion guards
object → object → scalar. There is no fourth level, because a string has no interior. That makes the claim "this path is exhausted" provable rather than merely un-complained-about — a materially stronger statement than "no findings this round". If a future pass finds something on this path, either the enumeration is wrong or the shape changed, and both are worth knowing.
These guards are a partial reimplementation of a decoder
Worth stating plainly, because it is the honest summary of this whole PR: Go, Kotlin and Swift needed none of these eleven rows. A typed decoder validates the entire path — body, arm, and every field — in one step, which is why their cells read "n/a — decoder" over and over. TypeScript, Python and Ruby needed every single row, and each review round found the next unguarded rung.
So these guards are not the permanent design. They are a stopgap for the three languages that have no runtime decoder on this route, and they exist only because GetTodolistOrGroup is modelled as a oneOf — which is what forced the untyped read path in the first place. #544 removes the root: one truthful flat shape means a decoder validates all three levels everywhere, and eleven hand-written guards collapse to zero. Every finding in this PR is an argument for it.
Rows 9 and 10 came from the ninth pass, and they are the evidence the matrix changed the search. Passes one through eight each found an existing rule missing in whichever language had not been swept. Once the sweep closed those, the ninth had to reach for genuinely new properties instead: the malformed envelope one level above the malformed field, and the guard's own error path failing while it explains a failure — JSON.stringify raises TypeError on a circular structure, so reporting a bad value could replace a clean api_error with an incidental one. Both were then swept across all six rather than fixed where they were found, which is how rows 1-8 should have been handled from the start.
Two of the row-9 cells were silently wrong rather than loudly broken, which is why they survived eight passes: Ruby's body["name"] on a String returns a nil substring match, and TypeScript's "todolist" in response on an array reports false and falls through to the flat branch. Both then self-corrected further down by accident. The scalar and null cases threw raw TypeErrors — the SDK's own error type nowhere in sight.
Negative results worth recording
Two axes were examined and found sound. Recording them so nobody re-derives them:
- Retryability is consistent across all five guards — every malformed-response error is non-retryable, which is correct because re-requesting cannot repair a malformed body. Kotlin's
httpStatus = 0is the in-repo convention for a statusless shape (BaseService.ktuses it for the pagination-origin error), not a divergence. - The guard tests survived a vacuity attack. Deleting the guard fails 16 tests; moving it after the PUT fails 14 on the request-log assertion. So both the
codepin and the["GET"]pin are load-bearing, proved by mutation rather than asserted. That is the standard the rest of this PR's tests should be read against.
That is not five unrelated bugs. Every one traces to the same decision or its absence: GetTodolistOrGroup is modelled as a oneOf, which is why Swift got a broken synthesised decoder and why Kotlin got an untyped JsonElement instead of a model. Python, Ruby and TypeScript were exposed for the adjacent reason — none has a decoder that rejects a wrong-typed field, so nothing was ever going to catch one for them.
Passes 4, 5 and 6 each corrected something stated earlier in this same PR: the "safe" column was twice too generous, both times because the test being applied was narrower than the failure mode, and then the fix for pass 5 shipped with assertions too narrow to police itself. The recurring lesson is the same in all three — the check has to name the thing that can actually be wrong.
The rule: a composite is safe exactly when a typed decoder sits between the GET and the field read. Go, Swift, and Kotlin's Todos and Cards get that for free from their models. Kotlin Todolists lost it to the union; Python and Ruby never had it. This is the strongest argument this PR can make for #544 — consolidating the three declared shapes into one truthful flat structure removes the root, not just these five symptoms.
Is this a class defect in the already-shipped composites? Partly — filed as #576
Three defects on three passes in one code path warranted checking whether the shape exists elsewhere, since the coercion trap is language-specific but "a lenient scalar accessor feeding a full-replace write" is not. Probed all six against the shipped Todos and Cards composites.
Safe, and safe structurally rather than by luck: Go, Swift, and Kotlin's Todos and Cards. Each reads a typed model, so the decoder rejects a wrong-typed field before the composite is handed it. Probed Go directly — json.Unmarshal into Description string errored on all of [], {}, 0, false, 42, true, aborting before the PUT.
Affected: Python, Ruby, and TypeScript, none of which have a typed layer between the GET and the field read. This is shipped code on main, filed as #576 rather than fixed here — it deserves its own reviewed change, not a ride-along on a triad PR. Severity is latent, not actively firing: it needs BC3 to return a non-string for a field, which it does not do today.
Correction — I first classified TypeScript as safe, and that was wrong. The stated reason was that ?? "" coalesces only null/undefined, so nothing is erased. That is true, and it is the wrong test: it rules out erasure while leaving corruption wide open. A wrong-typed value is not coalesced, it is passed through verbatim into a full-replace PUT. Probing the shipped helpers makes it concrete — TS Todos forwards all eight of false, 0, [], {}, 42, true, ["x"], {"a":1} unchanged, a broader corruption surface than Python's. TS Cards is worse in a different way: its if (current.due_on) drops falsey values, and an omitted due_on is exactly how BC3 erases a card's due date, so falsey corrupts by erasure and truthy corrupts by passthrough.
The deeper reason is the one this PR already states about the generated get signature: a TypeScript type is a compile-time claim about runtime data that nothing validates. schema.d.ts is erased at build time, so there is no decoder to reject a wrong type — unlike Go's json.Unmarshal, Swift's Codable, or kotlinx.serialization, which genuinely refuse. TypeScript therefore belongs with Python and Ruby structurally, not with Go and Swift. Applying the erasure-only test was the same mistake as reading ?? "" as a validator.
The rule that falls out, and the reason Todolists was the exception: a composite is safe exactly when a typed decoder rejects a wrong-typed field at runtime, between the GET and the field read. Not when a type merely claims one. Kotlin Todolists lost that decoder only because GetTodolistOrGroup is a oneOf, so the generator returns an untyped JsonElement — the same union modelling that produced layers 1 through 3. Python, Ruby and TypeScript never had one. Every layer traces back to that decision or its absence, which is what #544 removes.
Two existing test fixtures were wrong, and the guard exposed them
Both had to change, and why is a sharper warning than the fix:
testUpdate_refusesAGroupOnlyProjectionwas proving nothing while appearing to prove something. It built its "group-only" body by deletingdescriptionanddescription_attachmentsbut leftgroups_urlin — a todolist-exclusive key. That makes it a malformed todolist, not a group. It only reached the group arm, and only passed, because the masking bug laundered it. With the guard in place it correctly fails. Rebuilt as a realistic group body: no todolist-exclusive keys at all, withgroup_position_urlin place ofgroups_url, which is what BC3 actually emits.testUnionRejectsABodyMatchingNoArmasserted the wrong error. It expected the genericdataCorrupted("matched no variant"). An empty body now reports the first arm's realkeyNotFound("appUrl"). Updated, because surfacing the underlying cause is the same principle as the masking guard: the decoder never invents an error while it still holds a real one.
Behaviour change for Swift callers: todolists.get() now returns a populated value, surfaces the real decoding error for a malformed todolist instead of laundering it into the group arm, and throws on a body matching neither arm instead of returning an empty one.
The contract, from bc3 source
app/controllers/todolists_controller.rb:41-50 and its private new_todolist at :58-60:
def update
@recording.update! recordable: new_todolist
...
end
def new_todolist
Todolist.new params.require(:todolist).permit(:name, :description, :track_todolist)
end
It builds a brand-new Todolist from only the permitted params and swaps the recordable wholesale (Recording#recordable=, app/models/recording/recordables.rb:48). A field absent from the body is nil on the replacement.
- Omission clears. The public docs agree verbatim: "Pass all existing parameters in addition to those being updated. Omitting a parameter will clear its value." (
doc/api/sections/todolists.md:232) nameis genuinely required —validates :name, presence: true(app/models/todolist.rb:4) plusvalidates_associated :recordable, on: :update(recordables.rb:10) ⇒ 422, never a preserve. The spec's doc comment claimed this but never marked it@required; it does now.- Writable set is exactly
{name, description}.track_todolistis not on this surface:wrap_parameters Todolistdefaultsinclude:toTodolist.attribute_names, whichdb/schema.rb:1626-1629shows is onlyid/name/description, so the key never reachesparams[:todolist]on the JSON path. It is read top-level and applied bytoggle_hill_chart_tracking, which is key-guarded — a hill-chart side-effect directive, not recordable state.
SPEC §18 rule-by-rule
| Rule | Evidence |
|---|---|
| 1. No hand-written wire I/O | Every hop goes through the generated get and replace. Go uses the sanctioned rule-1 carve-out — one shared replaceTodolistOrGroup marshals an explicit body map through UpdateTodolistOrGroupWithBodyWithResponse, because omitempty cannot express always-send-empty. |
| 2. Composition, not substitution | GET → overlay → full PUT over existing operations. No new wire operation; op count stays 238. |
| 3. Native hook identities | Hooks observe GetTodolistOrGroup then UpdateTodolistOrGroup. Pinned by hook-spy tests in Go, TypeScript, Ruby, Python, Kotlin and Swift. |
| 4. Conformance-covered | conformance/tests/todolists_write.json, four cases, dispatched in all six runners. |
| 5. Declared placement | Kotlin EXTENSIBLE_SERVICES/HAND_WRITTEN_SERVICES; TypeScript src/services/todolists-extensions.ts wired in client.ts; Ruby zeitwerk prepend; Python service subclass re-exported by both clients; Swift same-module extension; Go wrapper layer. |
| 6. Raw operation stays reachable | UpdateTodolistOrGroup → replace via METHOD_NAME_OVERRIDES in all five service generators — renamed, not hidden. Its own case, replace-omission-clears, asserts requestCount: 1 with indexed requestMethod/requestPath on hop 0 and requestBodyAbsent on description. Without it, generator drift could turn both public methods into composite behaviour unnoticed. |
Body compaction is not relaxed: a clear is "", never {"description": null}.
Red proofs
Every language proved the destructive status quo against pristine origin/main (extracted with git show/git archive into scratch — no checkout, no stash).
Go
=== RUN TestRED_TodolistsUpdateNameOnlyMustPreserveDescription
todolists_triad_red_test.go:48: observed PUT /999/todolists/2 raw body: {"name":"Renamed list"}
todolists_triad_red_test.go:73: merge-safe Update must issue 2 requests (GET then PUT); got 1: [PUT /999/todolists/2]
todolists_triad_red_test.go:87: DESTRUCTIVE: the PUT body has no "description" key, so BC3 would CLEAR the description. body=map[name:Renamed list]
--- FAIL: TestRED_TodolistsUpdateNameOnlyMustPreserveDescription (0.00s)
Ruby
4) Failure:
TodolistsServiceTest#test_update_name_only_preserves_the_description:
The request GET https://3.basecampapi.com/12345/todolists/2 was expected to execute 1 time but it executed 0 times
The following requests were made:
PUT https://3.basecampapi.com/12345/todolists/2 with body '{"name":"Renamed list"}' was made 1 time
Swift — the union decoder defect has its own section above, with its red proof. The triad's own Swift red proof is the same sparse-PUT shape as the others.
TypeScript also proved the fixture is not vacuous — a mutant runner routing UpdateTodolist to raw replace fails both merge cases with expected 2 requests, got 1.
Six-runner dispatch
Scenario keys UpdateTodolist / EditTodolist / ReplaceTodolist (synthetic dispatch keys, commented as such, matching the EditTodo precedent) in Go, TypeScript, Python, Ruby, Kotlin and Swift. Local make check — REAL_EXIT=0, "All checks passed":
| Runner | Result |
|---|---|
| Go | 139 passed, 0 failed, 2 skipped |
| Kotlin | 140 passed, 0 failed, 1 skipped |
| TypeScript | 172 passed, 2 skipped |
| Ruby | 130 passed, 0 failed, 11 skipped |
| Python | 141 passed, 0 failed, 0 skipped |
| Swift | 140 passed, 0 failed, 1 skipped |
Every runner's total rose by exactly 4. No new skips — the roster in SPEC §19 is unchanged. Cite the CI job numbers over these.
Groups: one route, no branching
There is no separate group model or group write route. A "group" is a Todolist whose parent is another Todolist (Todolist.group?); there is no Todolist::Group class; and the API-canonical routes mount resources :groups, only: %i[ index create ]. Every API group write lands on TodolistsController#update through this same URI, and BC3 renders both variants through todolists/_todolist.json.jbuilder. The composite is therefore deliberately variant-agnostic — no type-sniffing — and the update-group fixture case pins it with a group-shaped GET body.
Go is the one asymmetry. TodolistGroupsService gets only the Update → Replace rename, and deliberately no merge-safe composite: the TodolistGroup schema does not model description, so a composite reading through that projection would PUT back a zero value and erase it on every call — the exact data loss this PR removes, through the back door. Swift hit the same wall independently and refuses a group-arm fallback for the same reason. The decision is pinned by a reversible guard:
if _, ok := reflect.TypeFor[TodolistGroup]().FieldByName("Description"); ok {
t.Fatal("TodolistGroup now models Description — the reason for withholding a merge-safe group " +
"Update/Edit is gone; see #544 and add the composite over the public Get")
}
ReplaceTodolistGroupRequest does carry description: the wire body is shared and the server accepts it, and without it a group replace was unconditionally destructive with no caller recourse. Replace is verbatim by definition, so this is control, not a merge illusion.
Breaking
todolists.update(...)changes meaning from sparse PUT to merge-safe composite. The old behaviour isreplace(...).nameis now required onreplace. Source-breaking in typed SDKs — e.g. Kotlin'sUpdateTodolistOrGroupBody(description = …)no longer compiles. Intended: the server presence-validatesname, so those calls were already 422s at runtime.- Go:
TodolistGroupsService.Update→Replace,UpdateTodolistGroupRequest→ReplaceTodolistGroupRequest. - Swift
todolists.get()now returns a populated value and throws on a body matching neither arm, instead of silently returning an empty one (see the section above).
behavior-model.json changes by exactly +4 lines — the write clause from the new @basecampWriteSemantics trait. No operations added or removed (238 before and after).
Two deviations from the plan, recorded
- No
UpdateTodolistOrGroup→ReplaceTodolistOrGrouprename. #545 proposed one; §18 rule 6 sanctions theMETHOD_NAME_OVERRIDESroute, which is what shipped and what Cards set precedent for (UpdateCard→updateVerbatim). Renaming the operation ID would churn provenance, url-routes and the api-gaps registry for no behavioural gain. - #544 did not land first. It was specified as the precursor. The triad needed only that the response decode, not the full three-shape consolidation — so this PR fixes the Swift oneOf emitter and leaves #544 open. Still worth doing: consolidating
Todolist,TodolistGroupandTodolistOrGroupinto one truthful flat structure, and modelling the fields the wire really sends (group_position_url,color,comments_app_url) that the schema still lacks.