Skip to content

Kotlin: stop coercing a wrong-typed scalar into a String (#598) - #660

Merged
jeremy merged 2 commits into
mainfrom
fix/598-kotlin-scalar-coercion
Aug 4, 2026
Merged

Kotlin: stop coercing a wrong-typed scalar into a String (#598)#660
jeremy merged 2 commits into
mainfrom
fix/598-kotlin-scalar-coercion

Conversation

@jeremy

@jeremy jeremy commented Aug 4, 2026

Copy link
Copy Markdown
Member

Closes #598.

Kotlin's client-wide Json carried isLenient = true. That relaxes RFC-4627 far enough to read a JSON number or boolean into a declared String, so "description": 42 decoded to "42" — and the merge-safe composites then PUT that fabricated value back to a full-replace endpoint on a call that never mentioned the field. The coercion happens inside the decoder, so the per-composite guard that fixed Python, Ruby and TypeScript in #597 is structurally incapable of catching it: by the time the composite runs, the value is an ordinary String with no way to know whether the wire carried 42 or "42".

The fix is one line: drop isLenient, keep coerceInputValues.

The flag attribution — isLenient, not coerceInputValues

The issue text and the release plan disagreed about the cause. They are not interchangeable, and removing the wrong one ships a no-op as a fix. The issue was right.

kotlin/sdk/src/commonTest/kotlin/com/basecamp/sdk/DecoderStrictnessTest.kt is new and pins the semantics of each flag in isolation, so the answer lives in the tree rather than in anyone's recollection:

  • lenientCoercesNumberIntoString / lenientCoercesBooleanIntoStringisLenient alone produces "42" and "false" from 42 and false. This is the defect.
  • coerceInputValuesDoesNotCoerceAScalarTypecoerceInputValues alone throws on {"description": 42}. It is not implicated, and dropping it would have been a no-op fix.
  • coerceInputValuesRewritesNullToTheDeclaredDefault / withoutCoerceInputValuesAnExplicitNullIsRejected — what coerceInputValues is actually for: an explicit null into a non-nullable property with a default. That is why it stays.
  • nullableFieldsAcceptExplicitNullEverywhere — the shape the SDK's own generated models use, so keeping or dropping coerceInputValues is invisible to them.
  • structuralMismatchIsRejectedEvenWhenLenient — arrays and objects were always refused. That is the half Python, Ruby and TypeScript merge-safe composites forward a non-string GET field into the full-replace PUT #576 correctly called safe, and it stays that way.

The tripwire flipped

TodolistsServiceTest carried a test that asserted the defect on purpose, and said so in its own doc comment:

This is a CROSS-SERVICE gap (#576) — the Documents composite has it too — not something a todolist-specific guard should paper over [...] This test records the exact behavior so closing #576 flips it visibly.

It asserted assertEquals(listOf("GET", "PUT"), capture.methods) and assertEquals("42", capture.putBody!!["description"]) — the coerced value landing on the wire.

It is now updateRefusesABareScalarDescriptionBeforeWriting and asserts the refusal: no PUT is issued, and the caller gets a statusless, non-retryable BasecampException.Api carrying a hint — for both a number (42) and a boolean (false), because isLenient accepted both and each produced a differently-shaped fabrication. That flip is the evidence the fix landed, on exactly the terms the original author asked for.

Todolists is a third affected service, beyond the Todos and Cards that #576 and #598 named. Documents and Schedules are the same composite shape and their comments are corrected here too.

Conformance: a bare-scalar kill case, and it needs no per-language skip

#598 anticipated a Kotlin-only fixture, since "no single value discriminates for both Kotlin (which needs a structural shape) and TypeScript Cards (which needs a falsey scalar)." That was true of the code as it stood. The decoder fix removes the asymmetry, so the fixture is better than anticipated: with isLenient gone, all six SDKs refuse a non-string scalar — Go, Kotlin and Swift in their model decoders (json.Unmarshal, kotlinx.serialization, Codable), and TypeScript, Python and Ruby in the hand-written writableString/write_string guards, whose non-string branch always covered 42. So conformance/tests/todos_write.json gains

update-kill: a bare-scalar description is refused before the full-replace PUT

as an ordinary six-runner case with zero entries added to any runner's skip map. Confirmed executing, not silently skipped, in all six: Go/Kotlin/Ruby/Python/Swift each print a PASS line, and TypeScript (which is non-verbose in the suite) was checked directly with npx vitest run -t 'bare-scalar' --reporter=verbose✓ conformance/todos_write.json > update-kill: a bare-scalar description is refused before the full-replace PUT.

conformance/check_kill_case_controls.py passes: the new body is the existing update-merge control's body with exactly one field perturbed, same as its array and object siblings.

It is a kill case, not decoration

Restoring isLenient = true locally and re-running make conformance-kotlin:

  FAIL: update-kill: a bare-scalar description is refused before the full-replace PUT
        Expected the call to fail, but it succeeded
Passed: 175, Failed: 1, Skipped: 1, Total: 177
MARKER_KT598_RED_EXIT=2

Reverted immediately; the committed tree has no isLenient assignment (git grep isLenient under kotlin/sdk/src/commonMain returns comment lines only).

Prose the fix falsified

Corrected only where the claim is now false — comments describing the scalar hole as an open cross-service gap, several of which also named the wrong flag pair:

  • TodolistsServiceTest.updateRefusesAMalformedDescriptionBeforeWriting — said arrays/objects were used because bare scalars get coerced; now cross-references the sibling.
  • DocumentsServiceTest, SchedulesServiceTest — same "An ARRAY, not a scalar" rationale.
  • DocumentsService.kt (×2), SchedulesService.kt, TodolistsService.kt — "(The client-wide coerceInputValues/isLenient scalar hole means a bare JSON scalar is coerced rather than rejected [...] not something this composite can close.)"
  • conformance/tests/todos_write.json — the two existing kill-case descriptions asserted a scalar "would NOT discriminate in Kotlin".

SPEC.md:1091 mentions coerceInputValues = true in the FlexibleIntSerializer discussion and is still accurate — that flag is unchanged — so it is left alone. Same for ReplayRunner.kt, whose stricter replay Json is unaffected.

Verification

Full suite run twice on the final tree, exit code captured via a marker written into the log and grepped back rather than trusted from a mid-run "BUILD SUCCESSFUL":

make kt-check conformance
MARKER_KT598_REAL_EXIT=0    (run 1)
MARKER_KT598_REAL_EXIT=0    (run 2)

Kotlin SDK checks passed and every runner was green. An earlier revision of this description claimed Passed: 176, Failed: 0, Skipped: 1, Total: 177 "in each runner" — that is Kotlin's and Swift's tally, not a shared one. The runners do not report a common shape, and their skip counts differ. The real per-runner numbers, from a fresh make conformance on the final tree:

Runner Passed Failed Skipped Total
Go 175 0 2 177
Kotlin 176 0 1 177
TypeScript 219 0 2 221
Ruby 166 0 11 177
Python 177 0 0 177
Swift 176 0 1 177
MARKER_CONFORMANCE_EXIT=0

TypeScript counts differently — it runs two suites, so 221 is not comparable to the others' 177. No test other than the deliberate tripwire needed flipping.


Summary by cubic

Stops Kotlin from coercing wrong-typed scalars into Strings by removing isLenient from the client-wide Json. Numbers/booleans are now rejected before any write, aligning Kotlin with the other SDKs and closing #598.

  • Bug Fixes
    • Removed isLenient from the client-wide Json; kept coerceInputValues for explicit nulls.
    • Strengthened tests: DecoderStrictnessTest pins each flag and now decodes through BasecampClient.json to guard the actual config.
    • Todolists: flipped the scalar test to assert refusal before PUT; updated Documents and Schedules tests and comments.
    • Cards: added a test to refuse a bare-scalar due_on from the server response.
    • Conformance: added a bare-scalar kill case to conformance/tests/todos_write.json; passes in all six SDKs with no skips.

Written for commit 0c3b16a. Summary will update on new commits.

Review in cubic

The client-wide Json carried `isLenient = true`, which relaxes RFC-4627 far
enough to read a JSON number or boolean into a declared String. `"description":
42` decoded to "42", and the merge-safe composites then PUT that fabricated
value back to a full-replace endpoint on a call that never mentioned the field.
The coercion happened inside the decoder, so the per-composite guard that fixed
Python, Ruby and TypeScript in #597 was structurally incapable of catching it:
by the time the composite ran, the value was an ordinary String.

`isLenient` is the culprit and `coerceInputValues` is not. The two are not
interchangeable and the release plan blamed the wrong one, so removing it would
have shipped a no-op as a fix. `coerceInputValues` rewrites an explicit null to
the declared default for a non-nullable property and has nothing to say about a
scalar type; it stays. DecoderStrictnessTest pins both behaviours in nine tests
so the attribution lives in the tree rather than in anyone's recollection.

The evidence that the fix landed is a tripwire flipping. TodolistsServiceTest
carried `updateCoercesABareScalarDescription`, whose own doc comment said it
recorded the coerced PUT "so closing #576 flips it visibly". It is now
`updateRefusesABareScalarDescriptionBeforeWriting` and asserts the refusal — no
PUT, a statusless non-retryable BasecampException.Api with a hint — for both a
number and a boolean. Todolists is a third affected service beyond the Todos and
Cards that #576 and #598 named; Documents and Schedules share the shape.

conformance/tests/todos_write.json gains a bare-scalar kill case. It needs no
per-language skip: with the decoder fixed, all six SDKs refuse a non-string
scalar — Go, Kotlin and Swift in their model decoders, TypeScript, Python and
Ruby in the hand-written writableString guards — so the case that had no home
before is now a six-runner regression guard. Restoring `isLenient` locally turns
it red (`Expected the call to fail, but it succeeded`, make conformance-kotlin
exit 2), which is what makes it a kill case rather than decoration.

The rest is prose the fix falsified: comments in DocumentsService,
SchedulesService and TodolistsService and their tests described the scalar hole
as an open cross-service gap.
Copilot AI balanced review requested due to automatic review settings August 4, 2026 18:29
@jeremy jeremy added bug Something isn't working kotlin labels Aug 4, 2026
@github-actions github-actions Bot added the conformance Conformance test suite label Aug 4, 2026

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

DecoderStrictnessTest built its own three Json instances and never touched
BasecampClient, so it pinned kotlinx.serialization's flag semantics and
nothing about this SDK's configuration. Restoring main's BasecampClient.kt
— isLenient and all — and running the whole file was green. The comment
claiming it "cannot drift from the semantics" was writing a cheque the test
did not cover.

`json` is internal and commonTest is the associated compilation, so add a
case that decodes through the instance BasecampClient builds. Against
main's client it fails and it is the only failure in the file; against this
branch's the file is green. Narrow the negative assertions from Exception
to SerializationException while here — every one of them throws it.

Cards had no wrong-typed-due_on coverage. #598 filed it as a read-modify-
write hazard, but #647 had already deleted the preservation GET and the
three Cards kill cases along with it, so there is no read-back left to
refuse before a PUT. What survives is the response decode: Card.dueOn is
String?, and under isLenient a bare-scalar due_on off the wire decoded to
"42"/"false" and reached the caller as an ordinary String. Cover that,
which is the shape the shared decoder still governs.
Copilot AI review requested due to automatic review settings August 4, 2026 19:03
@jeremy

jeremy commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Absorbed the review. C1 and C3 were right; C2 was right that Cards had no coverage but wrong about the shape it should take, and I have evidence rather than an opinion on that.

C1 — the comment was writing a cheque the test did not cover. BasecampClient.kt claimed "DecoderStrictnessTest pins both behaviours so this comment cannot drift from the semantics". It cannot: DecoderStrictnessTest.kt:34-36 builds its own three Json instances and the file never mentions BasecampClient. It pins kotlinx.serialization's flag semantics, not this SDK's configuration.

Reproduced the reviewer's proof: restoring origin/main's BasecampClient.kt (isLenient = true) and running the file alone was green, 10/10.

json is internal and commonTest is the associated compilation, so it is reachable. Added theClientsOwnDecoderRefusesAWrongTypedScalar, which builds a real client via testBasecampClient and decodes {"description": 42} / {"description": false} through client.json — plus an explicit null into a non-nullable probe, so coerceInputValues staying on is pinned too.

RED, with origin/main's BasecampClient.kt swapped in:

DecoderStrictnessTest[jvm] > theClientsOwnDecoderRefusesAWrongTypedScalar()[jvm] FAILED
    org.opentest4j.AssertionFailedError at DecoderStrictnessTest.kt:126
10 tests completed, 1 failed
MARKER_C1_RED_EXIT=1

It is the only failure — which is the reviewer's point restated as a number: the nine pre-existing cases stay green against the un-fixed client.

GREEN, on this branch:

MARKER_C1_GREEN_EXIT=0
BUILD SUCCESSFUL

(The swap was done with git show origin/main:<path> and restored the same way, never git stash — this worktree shares a ref store with ~30 others.)

Narrowed the six assertFailsWith<Exception> to SerializationException. All six pass narrowed, so every one of those cases really does throw it; none needed to stay broad. Reworded the comment to name the new test rather than the file.

C2 — Cards genuinely had no coverage, but the requested shape is no longer constructible. The ask was to mirror updateRefusesABareScalarDescriptionBeforeWriting: GET returns a bare-scalar due_on, cards.update refuses before the PUT, assert no PUT was issued. cards.update issues no GET. #64746b7f8225, the parent commit of this branch — deleted the preservation GET:

With omission now meaning "unchanged", the read-modify-write preservation GET has nothing left to protect, so it goes too. update is a single PUT in every case.

and removed the three Cards kill cases from conformance/tests/cards_write.json in the same commit, for exactly this reason:

-    "name": "update-kill: an array due_on is refused before the replacement PUT",
-    "name": "update-kill: an empty-object due_on is refused, not coerced or dropped",
-    "name": "update-kill: a date-shaped array due_on is refused where the format check is blind",

CardsService.kt is now a straight delegation to updateVerbatim. There is no read-back to refuse and no PUT to suppress; the first request the method makes is the PUT. #598's table describes the pre-#647 code.

What does survive is the response decode, and it is the same shared decoder: updateVerbatim ends in json.decodeFromString<Card>(body), and Card.dueOn is String?. Under isLenient a bare-scalar due_on coming back off the wire was coerced and handed to the caller as an ordinary String. So I covered that instead — updateRefusesABareScalarDueOnFromTheWire, both 42 and false, asserting the refusal and that exactly one PUT was issued.

It goes RED against the un-fixed client, and the failure message is the #598 defect verbatim:

CardsServiceTest[jvm] > updateRefusesABareScalarDueOnFromTheWire()[jvm] FAILED
7 tests completed, 1 failed
MARKER_C2_RED_EXIT=1

a bare-scalar due_on (42) must be refused, not rendered as text.
Expected an exception of class kotlinx.serialization.SerializationException to be thrown,
but was completed successfully with the result: <Card(id=42, ..., dueOn=42, ...)>

dueOn=42 — a fabricated String on a String? field, exactly what the issue reported. GREEN on this branch: MARKER_C2_GREEN_EXIT=0.

If you would rather this were pinned in conformance than in a unit test, say so and I will add it there; I kept it local because the equivalent conformance cases were deliberately retired by #647.

C3 — the numbers were wrong, corrected in the body. "Passed: 176, Failed: 0, Skipped: 1, Total: 177 in each runner" is Kotlin's and Swift's tally, presented as if shared. Re-ran make conformance on the final tree:

Runner Passed Failed Skipped Total
Go 175 0 2 177
Kotlin 176 0 1 177
TypeScript 219 0 2 221
Ruby 166 0 11 177
Python 177 0 0 177
Swift 176 0 1 177

Matches the reviewer's figures on every runner. TypeScript's 221 is two suites, not comparable to the others' 177.

Verification (exit codes written into the logs under markers and grepped back):

make kt-check      MARKER_KTCHECK_EXIT=0
make conformance   MARKER_CONFORMANCE_EXIT=0

Incidental confirmation from the Ruby conformance output, which bears on #656's README fix: PASS: DownloadURL retries on 503 at the auth'd first hop / PASS: DownloadURL does not retry hop 1 on 500.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jeremy

jeremy commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Merging on independent adversarial review; both bot reviewers were unavailable this session.

The headline finding is one the issue and the release plan disagreed about, settled by experiment rather than argument: isLenient is the culprit, not coerceInputValues. A permutation probe pins it — isLenient reads 42 into a declared String; coerceInputValues only rewrites an explicit null to a declared default and has no opinion on scalar type. Dropping the flag the plan named would have shipped a no-op as a fix.

Blast radius was swept rather than assumed, since this changes a client-wide decoder during a freeze: 229 .kt sources, 71 conformance fixtures and 124 spec/fixtures/** contain zero unquoted keys, single quotes, NaN/Infinity, or quoted-numbers-into-numerics reaching the client decoder. The only lenient-shaped JSON in the tree is the kill fixture this PR adds. Apparent counterexamples resolve: FieldKeyed422Test's "error_description": 42 goes through a tree parse whose stringMember rejects non-strings, and the Flexible*SerializerTest literals call decodeJsonElement() themselves. git log -S puts isLenient in the original SDK commit, not in response to any BC3 shape — it was never a deliberate accommodation.

Two things fixed after review:

  • DecoderStrictnessTest built its own Json instances and never touched BasecampClient, so it could not see this fix — proven by running it green against the un-fixed client — while the client comment claimed it "cannot drift from the semantics". Added theClientsOwnDecoderRefusesAWrongTypedScalar, which decodes through the instance the client actually hands every service. Verified red (that test the only failure) then green. Also narrowed six assertFailsWith<Exception> to SerializationException.
  • The conformance numbers in the body were wrong and are now the measured per-runner figures.

One correction to my own request: I asked for a Cards test asserting refusal before the PUT. That is not constructible — #647, this branch's parent, deleted the Cards preservation GET and removed those update-kill cases as unreachable, so cards.update is now a straight delegation to updateVerbatim with no GET. Covered the path that does survive (the response decode, Card.dueOn being String? through the shared decoder) with its own red/green instead.

Worth recording: the decoder fix removed the asymmetry #598 assumed. The issue expected a Kotlin-only kill case needing five skips, because no single value discriminated for both Kotlin and TypeScript Cards. With Kotlin fixed a bare scalar discriminates in all six, so the case landed as an ordinary six-runner fixture with zero skip entries — the scalar half of the contract is now pinned everywhere, which the issue described as unguarded in Kotlin and only in Kotlin.

Not labelled breaking, following #597 — the identical fix for TypeScript, Python and Ruby — which shipped without it.

@jeremy
jeremy merged commit a3174cf into main Aug 4, 2026
43 of 44 checks passed
@jeremy
jeremy deleted the fix/598-kotlin-scalar-coercion branch August 4, 2026 19:09
jeremy added a commit that referenced this pull request Aug 4, 2026
Rebased onto 2afc977 and re-measured rather than incremented. Eight PRs merged
since the branch was last updated, not the seven that carried the breaking
label: #647 was on the "Not in this release" list and had landed.

Counts. 55 class A and 6 class B, 61 surviving a clean build, up from 47/4/51.
Per SDK the class split is Go 12/4, Swift 10/0, TypeScript 9/0, Python 8/0,
Ruby 10/1, Kotlin 6/1, and the breaking-change column moves to 33/22/18/16/20/17.
The body parses back to those numbers rather than agreeing with them by hand.
The root README's aggregate sentence is re-derived to match, and now states both
halves numerically instead of "most" and "a few". The operation inventory is
unchanged at 238 -> 247 with the same 14 added, 5 removed and 11 same-ID route
moves, computed from openapi.json at both ends. check-targets is 43, and the
derivation is inline where the gate count was previously only projected. The
release spans 67 merged PRs, 15 labelled breaking; the gh commands that produce
both are embedded in the as-of block, with the note that a labelled PR is not
the same unit as an entry, which is why the per-SDK columns exceed 15.

#658 is class B, not class A. It does to five wrapper timestamps exactly what
#615 did to five others: QuestionReminder.RemindAt, ClientApprovalResponse's
CreatedAt and UpdatedAt, TimelineEvent.CreatedAt and WebhookDelivery.CreatedAt
compile untouched through a value-receiver call and panic on nil. #615's own
check could not see them because it keyed on the omitempty tag and these five
did not carry one. The audit is ten fields, and the entry names the near-miss
siblings that did not move, ClientApproval's pair in particular.

#664 splits. The public CreateScheduleEntryRequest fields were already string
and still are, so the wrapper half is silent: the RFC3339 ErrUsage guard is gone,
a bare date now creates an all-day entry, and a malformed value reaches bc3
instead of failing locally. That is class A. The generated
CreateScheduleEntryRequestContent went time.Time to string, which is a compile
error for pkg/generated importers. ReplaceScheduleEntryRequestContent is not a
migration from v0.12.0 at all; #632 introduced it. TypeScript and Ruby are
doc-comment only.

#647 is folded in as merged, with two corrections to what was written when it
was still a branch. It touches no schema, so the claim that it had to go
Smithy-first is withdrawn; UpdateCardStepRequestContent.DueOn was pointerized by
#560. And the v0.12.0 preservation GET was conditional, taken only when the
caller left due_on unaddressed, so the request-count table is scoped to that
path rather than presented as universal.

#648 adds no silent break anywhere. bc3's body is byte-identical before and
after, so nothing that was populated stops being so; the assignable's title was
never sent and is now spelled content. Every rename and retype is caught
statically in Go, Swift, TypeScript and Kotlin and raised immediately in Python
and Ruby, so it is one compile-or-runtime entry per SDK.

Two corrections nobody asked for. The Go class list opened "Go carries every
class-B break in the release", which stopped being true when Ruby's decode
entry moved into class B; it now claims only the panic-shaped ones. And
todos_write.json carries three errorRaised cases, not two, because #660 added a
bare-scalar kill.

#660 is a Kotlin class-B entry, which is new. Removing the client-wide isLenient
means a present, populated, wrong-typed scalar throws SerializationException
where it used to coerce to a string, and no signature moved to announce it. It
throws in the response decode, so on a write the mutation has already landed,
and it is not a BasecampException outside todolists.

#656 is Ruby class A, scoped tightly: only max_retries 0, only an ungoverned GET,
which means get_absolute and the Launchpad fetch rather than any operation
lacking a policy. Every other configuration is bit-identical.

Not in this release is now empty, and says so.
jeremy added a commit that referenced this pull request Aug 4, 2026
* MIGRATING.md: the v0.13.0 upgrade guide, silent breaks first

v0.13.0 breaks all six SDKs and 35 of those breaks are silent — no compile
error, no exception, no decoder failure. Label-generated release notes list
what merged; they cannot say what a consumer must react to or what wrong
behaviour they get if they ignore it. That had no home in this repo.

Adds MIGRATING.md at the root, linked from the root README and all six
per-SDK READMEs. Silent breaks lead the document, then one section per SDK
ordered by severity, plus an operator checklist, a "coverage: corrected and
re-scoped" section for what did not ship, and known gaps.

No CHANGELOG is reintroduced. The hand-maintained ones were deleted in #115
as superseded by auto-generated notes, and every release body since is
machine-built. CONTRIBUTING records the resulting rule: label-generated notes
say what merged, MIGRATING says what to do about it.

Corrections to the source drafts, each re-derived rather than repeated:

- TrashTodo was not a 404. bc3 draws `resources :todos, only: %i[show edit
  update destroy]`; DELETE /todos/:id returned 204 and set status to
  "archived", so every caller was archiving. It is the one #619 removal that
  takes away a working call, and it now carries its own carve-out.
- #619 removed three operations, not nine. Nine were re-pathed. Fusing the
  two sets is what made the blanket 404 reassurance look safe.
- Hook operation identity differs by SDK: Go and Ruby emit a short verb,
  the other four emit the wire operation ID, where the todolist pair kept
  its names — so an allowlist holding UpdateTodolistOrGroup passes the write
  and denies the new read.
- 238 -> 241 measured at the v0.12.0 tag and at c95d81c, not assumed.
- Kotlin binary compatibility is already disclaimed in kotlin/README.md;
  Swift has no written policy. Both are now stated rather than left unsaid.

recordings.get is documented as a known gap with a list-and-filter recipe
and its honest cost. The Go recipe compiles against this tree.

#637, #629 and #635/#641 were open at the time of writing and are recorded
under "Not in this release" rather than described as shipped.

* Fix the Go pagination advice, cut the raw-wire workaround, absorb #637/#643

Addresses both P1 review threads on #642 and folds in the two PRs that landed
since the first draft.

Pagination (P1). Cross-SDK item 1 claimed `page` was a starting offset in every
SDK and told readers to drop it to restore the old walk. For Go that was
actively harmful: `git show v0.12.0:go/pkg/basecamp/bookmarks.go` returns before
followPagination whenever page > 0, so a positive Page already meant one
request, and dropping it converts a bounded call into a full account-wide
traversal. The item is now scoped to the five SDKs where it holds — re-checked
at the tag rather than assumed, since the universal claim had already failed
once — with a Go subsection splitting the two real cases: services where the
page number was already honored (Bookmarks, Drafts, Everything*, request
unchanged) and the fourteen carrying the "not yet honored" doc, which sent no
page at all and returned page 1's rows. Gauges is in neither; it had no page.

Raw wire (P1). The Forwards().CreateReply example built a path with fmt.Sprintf
and called the raw AccountClient.Post against a route with no upstream
coverage, which is what AGENTS.md "Never Do These" 4 and 5 forbid. Removed
rather than softened, and replaced with a known-gap section stating what a
hand-built path gives up. Swept the document: the one other hit documents a real
change to the raw client's error codes, so it stays, but its fabricated path is
gone and it now says it is not a suggestion to reach for the escape hatch.

#643 landed, so basecamp.Ptr and basecamp.Deref replace the hand-rolled ptr
helper throughout, the Go section opens with the 300-pointer census and a
command that reproduces it, and ParticipantIDs *[]int64 gets its own note: nil
leaves participants alone, a pointer to an empty slice removes every one.

#637 landed and does NOT add a break to any SDK. color and comments_app_url did
not exist on Todolist at v0.12.0 in any of the six — both arrived with #628
earlier in this same release — so from the guide's baseline nothing turned from
optional to required. Counts stay 27/20/16/14/16/14. Documented where it bites:
color is required-and-nullable so explicit null decodes, comments_app_url
rejects null and absence alike.

Also: kotlin/README's append-only source-compat promise contradicted this
release repeatedly, so it now describes documented pre-1.0 breaking correctness
releases; the binary-compat disclaimer is kept and sharpened. release-github.yml
links MIGRATING.md from every release body, guarded on the file, so the link
cannot be forgotten at tag time. "Silent" is defined as source/runtime-silent
against a live server, since a suite pinning request paths does catch some.

Counts are stated as-of 51d0d86 with derivations inline, and each in-flight
change names the numbers it invalidates so the pre-tag pass is arithmetic.

* Split silent breaks into no-signal and fails-at-runtime; absorb #629 and cards

Addresses the remaining P2 and a suppressed Copilot comment on #642, re-derives
every count against main, and writes the cards due-date change.

The P2 was right, and it was a contradiction with this guide's own definition
rather than loose wording: "silent" was defined as "does not raise" and then
used to file nil-pointer panics. The section is now "Breaks your compiler will
not catch" — the property all of it actually shares — split into class A, no
signal at all, and class B, compiles then panics or raises but only when a
particular field is absent, so it passes every test where that field is
populated. Applying the definition consistently moved four entries, not the
three flagged: the three Go pointerization panics plus Ruby's
Draft#scheduled_posting_at decode, which raises NoMethodError and TypeError and
had the same defect. Two moved entries carry real no-signal residue, kept as
sub-notes rather than double-counted. Per SDK: Go 8A/3B, Swift 9A, TypeScript
5A, Python 4A, Ruby 2A/1B, Kotlin 3A — 31 + 4 = 35, unchanged in total. Body
counts verified against the table by parsing the section, not by eye.

The Swift section claimed three new optional Todolist members and named one;
the other two are required. Now singular, matching TypeScript.

Counts re-derived at 9de44b2: the inventory is 238 -> 247, not 241, since
#629 merged. Added, removed and route-moved lists are computed from openapi.json
at both ends rather than hand-edited — 14 IDs added, 5 removed, 11 same-ID moves
— and the Folders operations are flagged as drawn at /stacks, not /folders.

Cards get their own section. The half that matters most is true in production
today and is not caused by upgrading: every released SDK encodes "clear a card
due date" as omission, bc3 stopped treating omission as a clear, so that call is
a silent no-op right now. That is a reason to upgrade rather than a hazard of
it, so it sits in the operator checklist. The SDK-side change is read from
bf43715 and marked unmerged: single PUT, "due_on": "" as the clear encoding,
UpdateStepRequest.DueOn becomes *string, and the GetCard preservation read goes
away. The hook collapse is written as the inverse of the {Todolists,Update}
split because it fails the opposite way — allowlists do not start denying, but a
denylist on {Cards,Get} silently stops blocking the write it used to take down.
Removing the preservation GET also removes three named errorRaised kill cases
from cards_write.json; the class stays pinned on Todos, which still does a real
read-modify-write, so that is said rather than filed as a redundant-GET cleanup.

* Audit class A across all six SDKs; add Ruby's missing download retry

Fourth review round on #642. Four findings, all upheld.

The allowlist framing was wrong in the direction that matters. I wrote that
fewer hook events are safe for an allowlist. True only if the allowlist named
both operations: one that names UpdateCard and deliberately omits GetCard used
to reject cards.update at its read, and after the collapse permits it end to
end. Both policy shapes now carry the warning, labelled, plus the observation
that they are the same hole seen twice — in each, the thing stopping the write
was the read, expressed once as an omission and once as an entry.

The class-A counting was inconsistent across all six SDKs, not the two flagged.
Python and Kotlin excluded changes their own prose called "no signal
whatsoever"; auditing every SDK against the definition moved the totals to 47
class A and 4 class B. The counting policy is now stated in the document so it
can be checked against a rule rather than an impression: one entry per distinct
change per SDK, counted where it bites; class A if any ordinary call-site shape
stays silent even when another is compile-caught; second faces annotated as
residue and counted once; raises-only-on-malformed-response is class B.

Two things fell out that were not counting problems. Ruby's #563 was missing
from the guide entirely — no mention of download_url anywhere in the chapter —
verified against source rather than prose: v0.12.0 http.get_no_retry, which
sent Accept: application/json and did not retry, became get_download calling
request_with_retry with retry_on: DOWNLOAD_RETRY_ON and accept: nil. Ruby now
has its own section. The same check confirmed Go's omission of #563 is correct,
because Go already retried at v0.12.0. Separately, the Go note claiming the
compiler catches only the pkg/generated half of Schedules().UpdateEntry was
false: UpdateScheduleEntryRequest's fields became pointers, so any pkg/basecamp
call site that set a field fails to build.

The class-B definition described only half its own membership. It said the
trigger is an absent field, but Ruby's entry fires only when the field is
populated. It now says both, and says plainly that class B is a property of a
call plus a response rather than of the call — the same method against the
other shape is not a break at all. Class A has no such dependency.

Stale counts in the chapter intros are fixed. The Go intro still said eleven
silent and two panics, which is the first thing a #go link shows, and Swift
claimed the most no-signal breaks, which stopped being true at Go ten.

Also folds in #652 (projected-example gate, stacked on #648, takes check-targets
to 43), moves #648 out of draft at cb438ce, and records that #647 is being
reworked Smithy-first because the generated UpdateCardStepRequestContent.DueOn
is *types.Date and cannot express "". The consumer-facing card shape is
unaffected by that rework. Re-derived against #648: 238 -> 247 with 14 added,
5 removed and 11 same-ID route moves survives unchanged.

* Correct four claims in the v0.13.0 guide that do not match the source

The opening warning said the runtime failures need a payload where a field is
absent. That holds for the three Go entries; Ruby's single class-B entry has the
opposite trigger. Draft#scheduled_posting_at and MyNote#created_at/#updated_at
run through parse_datetime, which returns nil for nil and a Time otherwise, so
.start_with? and Time.parse raise only when the field is populated. A reader
following the old text builds the wrong fixture and concludes they are
unaffected. Both directions are now named, here and in the root README.

Class A was described as breaking on every response. Most of it does, but two
groups do not: the error-message and validation entries need an error status to
reach the code at all, and the field-map half needs a body of a particular
shape; downloadURL's hop-1 retry changes nothing until a network error or one of
429/502/503/504 occurs. Stated as preconditions rather than as a blanket claim.

The Go pointer example said only the field selector panics. types.Date.String
has a value receiver, so Go rewrites t.DueOn.String() to (*t.DueOn).String() and
the nil dereference panics before String is entered. The same holds for IsZero,
Before, After and Weekday on Date and for Format, Sub, Unix and Year on
time.Time. The summary bullet already said both panic; the example contradicted
it.

The Accept-header note credited only Python. Ruby dropped it on the same hop:
get_download passes accept: nil, and request_headers sets the header only when
accept is truthy. Both are named, with the observation that the other four never
sent it on that hop at v0.12.0 either.

No counts are touched.

* Re-derive every count against the final release commit

Rebased onto 2afc977 and re-measured rather than incremented. Eight PRs merged
since the branch was last updated, not the seven that carried the breaking
label: #647 was on the "Not in this release" list and had landed.

Counts. 55 class A and 6 class B, 61 surviving a clean build, up from 47/4/51.
Per SDK the class split is Go 12/4, Swift 10/0, TypeScript 9/0, Python 8/0,
Ruby 10/1, Kotlin 6/1, and the breaking-change column moves to 33/22/18/16/20/17.
The body parses back to those numbers rather than agreeing with them by hand.
The root README's aggregate sentence is re-derived to match, and now states both
halves numerically instead of "most" and "a few". The operation inventory is
unchanged at 238 -> 247 with the same 14 added, 5 removed and 11 same-ID route
moves, computed from openapi.json at both ends. check-targets is 43, and the
derivation is inline where the gate count was previously only projected. The
release spans 67 merged PRs, 15 labelled breaking; the gh commands that produce
both are embedded in the as-of block, with the note that a labelled PR is not
the same unit as an entry, which is why the per-SDK columns exceed 15.

#658 is class B, not class A. It does to five wrapper timestamps exactly what
#615 did to five others: QuestionReminder.RemindAt, ClientApprovalResponse's
CreatedAt and UpdatedAt, TimelineEvent.CreatedAt and WebhookDelivery.CreatedAt
compile untouched through a value-receiver call and panic on nil. #615's own
check could not see them because it keyed on the omitempty tag and these five
did not carry one. The audit is ten fields, and the entry names the near-miss
siblings that did not move, ClientApproval's pair in particular.

#664 splits. The public CreateScheduleEntryRequest fields were already string
and still are, so the wrapper half is silent: the RFC3339 ErrUsage guard is gone,
a bare date now creates an all-day entry, and a malformed value reaches bc3
instead of failing locally. That is class A. The generated
CreateScheduleEntryRequestContent went time.Time to string, which is a compile
error for pkg/generated importers. ReplaceScheduleEntryRequestContent is not a
migration from v0.12.0 at all; #632 introduced it. TypeScript and Ruby are
doc-comment only.

#647 is folded in as merged, with two corrections to what was written when it
was still a branch. It touches no schema, so the claim that it had to go
Smithy-first is withdrawn; UpdateCardStepRequestContent.DueOn was pointerized by
#560. And the v0.12.0 preservation GET was conditional, taken only when the
caller left due_on unaddressed, so the request-count table is scoped to that
path rather than presented as universal.

#648 adds no silent break anywhere. bc3's body is byte-identical before and
after, so nothing that was populated stops being so; the assignable's title was
never sent and is now spelled content. Every rename and retype is caught
statically in Go, Swift, TypeScript and Kotlin and raised immediately in Python
and Ruby, so it is one compile-or-runtime entry per SDK.

Two corrections nobody asked for. The Go class list opened "Go carries every
class-B break in the release", which stopped being true when Ruby's decode
entry moved into class B; it now claims only the panic-shaped ones. And
todos_write.json carries three errorRaised cases, not two, because #660 added a
bare-scalar kill.

#660 is a Kotlin class-B entry, which is new. Removing the client-wide isLenient
means a present, populated, wrong-typed scalar throws SerializationException
where it used to coerce to a string, and no signature moved to announce it. It
throws in the response decode, so on a write the mutation has already landed,
and it is not a BasecampException outside todolists.

#656 is Ruby class A, scoped tightly: only max_retries 0, only an ungoverned GET,
which means get_absolute and the Launchpad fetch rather than any operation
lacking a policy. Every other configuration is bit-identical.

Not in this release is now empty, and says so.

* State the schedule-entry clear value per field instead of universally

The Swift Behavioural bullet said an explicit "" clears any of the five
full-state fields. Only description does. "" on summary is accepted and
reads back "Untitled"; starts_at and ends_at are under
validates_presence_of in Schedule::Entry, so "" is rejected rather than
cleared; allDay is a boolean in every SDK, so "" does not typecheck at
all. The carve-out half grouped notify with the three clearable fields
even though it is a send directive with no state to clear.

* Re-derive the per-SDK README banners against the final class A/B table

The six SDK README banners still carried the counts from before the Go
reclassification and the recount that followed it, summing to 51 where
MIGRATING.md and the root README say 61. Each banner now matches its row
in the class A/B table: Go 12+4, Swift 10, TypeScript 9, Python 8, Ruby
10+1, Kotlin 6+1. Kotlin also gains the runtime clause it was missing,
since its one class B entry throws on a present field carrying a JSON
number or boolean where the model declares a string.

* Correct the merged-PR count and the two claims the reviewers caught

The release spans 55 merged pull requests, not 67. The 67 came from comparing
GitHub's Z-formatted mergedAt against a git timestamp formatted with a local
offset, using jq's string >, which is lexicographic rather than temporal; it
wrongly swept in twelve PRs merged in the hours before the v0.12.0 tag instant.
The derivation embedded in the guide taught that same broken comparison, so it
now uses %ct and fromdateiso8601 and says why. The breaking count of fifteen is
unchanged, since all fifteen merged after the tag, so the class A/B split, the
per-SDK tables and the six README banners are untouched.

The header no longer calls 2afc977 the commit the release is cut from. That
commit is the last of the release content and the baseline the counts were
measured against, but it predates this guide; the tag is cut from main after
this merges, on a tree that contains the file the release body links to.

The release-body teaser claimed the guide covers only breaks with no exception
and no decoder failure. The guide documents six breaks that do fail at runtime,
including Ruby and Kotlin raises and a Kotlin decoder failure, so the teaser now
names both the silent class and the runtime one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working conformance Conformance test suite kotlin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kotlin coerces a wrong-typed scalar into a String, so the merge-safe composites write it back

2 participants