Publish Todolist.color and comments_app_url as required (#630)
Closes #630.
BC3 emits color and comments_app_url on every projection of Todolist, and the published contract said they might be absent. _todolist.json.jbuilder calls json.color in both branches of its todolist_group? conditional, and emits comments_app_url from bucket_recording_comments_url — a route helper, which returns a String or raises. Optional pushed an absence-check onto every consumer, in every language, for keys that are never absent.
Both become required. Operation count is unchanged at 241 (re-derived from behavior-model.json, which does not move): this is a field-presence change, not a surface change.
Why color goes through the projection and comments_app_url does not
color is required and nullable. recordings.color is a nullable integer column, so an uncolored list or group sends an explicit null — for a group, per bc3, that is the ordinary case.
Native Smithy @required cannot express that on this shape. Todolist carries @examples (via GetTodolistOrGroup), and Smithy cannot put a null into an example for a String shape, so @required fails validation two ways: Missing required structure member 'color' if the examples stay faithful, Expected string value for string shape 'smithy.api#String'; found null value if you try to supply the group's true value. The workaround — a fictional non-null example — trades a faithful example for a type the projection can state anyway. The sibling shapes carrying the same field (Wormhole, Folder, FolderWithProjects) are natively @required only because none of them carries examples.
So the presence half is layered onto the OpenAPI projection alongside the nullability half that was already there, one pointer in spec/smithy-build.json:
"/components/schemas/Todolist/properties/color/type": ["string", "null"],
"/components/schemas/Todolist/properties/color/x-go-type": "string",
"/components/schemas/Todolist/required/-": "color",
jsonAdd applies JSON-Patch add semantics, so required/- appends to the array rather than replacing it. The Smithy member stays natively optional and the null example is untouched:
$ make smithy-build LANE630_SMITHY_BUILD_EXIT_IS 0
$ cd spec && smithy validate
SUCCESS: Validated 3629 shapes (WARNING: 1)
LANE630_SMITHY_VALIDATE_EXIT_IS 0
comments_app_url is never null, so it has no null-in-example problem and takes native @required. Its only cost is that both examples must now carry the key — a real in-app comments URL, not a fiction. Confirmed against bc3 at the pinned revision 4dd2926f8af0 (spec/api-provenance.json), app/views/api/todolists/_todolist.json.jbuilder:
if todolist_group?(recording)
json.color recording.color
else
json.color recording.parent.hill_chart&.color_for(recording) || recording.color
end
...
json.comments_app_url bucket_recording_comments_url(recording.bucket, recording, api_app_url_options)
The color doc comment argued for optional on fixture-cost grounds ("Optional is the weaker, safer claim…"). That reasoning is superseded and is replaced by the projection rationale, so nothing in the model contradicts the model.
The projected examples needed the same treatment — and nothing checks that
Appending to required in the projection made both GetTodolistOrGroup response examples invalid against the schema they illustrate, and smithy validate cannot see it: it validates @examples against the Smithy model, where the member is still natively optional. The requiredness only exists downstream. A bot reviewer caught it, not CI.
Fixed the same way, in 12b02cda8:
"…/examples/GetTodolistOrGroup_example1/value/result/color": "blue",
"…/examples/GetTodolistOrGroup_example2/value/result/color": null,
"blue" for the list, an explicit null for the uncolored group. Writing them in examples.smithy is not an option for the same reason @required was not: no null in a String example, and a made-up color for the group trades a faithful example for nothing. Verified by diffing each example against Todolist.required rather than by eye:
GetTodolistOrGroup_example1: color="blue" comments_app_url_present=true missing_required=[]
GetTodolistOrGroup_example2: color=nil comments_app_url_present=true missing_required=[]
The seam is real and is now #638: any required/- jsonAdd is unchecked against the projected examples. Two pointers do that today, both added here. A gate is deliberately not in this PR — it holds the v0.13.0 spec train with #629 draft-held behind it, and a new CI check wants its own review plus the self-test this repo asks of its checkers.
What consumers see — this is the breaking part
| SDK | before | after |
|---|---|---|
| TypeScript | color?: string | null / comments_app_url?: string | color: string | null / comments_app_url: string |
| Kotlin | val color: String? = null / val commentsAppUrl: String? = null | val color: String? / val commentsAppUrl: String |
| Go | Color *string \json:"color,omitempty"`/CommentsAppUrl *string `…,omitempty`` | Color *string \json:"color"`/CommentsAppUrl string `json:"comments_app_url"`` |
| Swift | public var color: String? / public var commentsAppUrl: String? | public let color: String? / public let commentsAppUrl: String, both required init params |
| Python | NotRequired[str | None] / NotRequired[str] | str | None / str |
| Ruby | optional accessor group | required_fields, and to_h keeps an explicit null color |
Nullability is preserved everywhere color is concerned — Go stays *string, Kotlin and Swift stay optional-typed. Only presence changed, which is the whole point. comments_app_url is never null, so it becomes a non-optional type in the four typed SDKs.
Two consequences worth naming:
- Go's
CommentsAppUrlgoes pointer → value. The hand-written wrapper'sderef(gtl.CommentsAppUrl)stopped compiling (type string does not match *T) and is now a plain assignment. That is a compile break for anyone touchinggenerated.Todolistdirectly. - Ruby's
to_hno longer drops a nilcolor. The generator switched that struct from.compactto.reject { |k, v| v.nil? && !["color"].include?(k) }, so a null color round-trips as an explicit"color" => nilinstead of vanishing.
Migration: a consumer who tolerated an absent color is fine at runtime — the wire never changed. What breaks is the generated type: a Kotlin String? with a default, a Swift optional, a Go pointer, a TS ?: all become required, so exhaustive constructors and struct literals need the field. This is in v0.13.0 because optional → @required is itself breaking; deferring it does not defer the cost, it relocates it into a release with no breaking window.
Swift's diff is ~110 lines, not one — and it is the generator's documented path
Making color required-and-nullable pushes Todolist over the threshold where ModelEmitter.emitRequiredNullableCoding replaces the synthesised Codable with an explicit CodingKeys + init(from:) + encode(to:). Per member: required-and-nullable → decode(T?.self) (rejects a missing key, accepts JSON null); required → decode(T.self); optional → decodeIfPresent.
The CodingKeys cases are bare case appUrl with no raw value, which is correct here and not a bug: BaseService sets .convertFromSnakeCase/.convertToSnakeCase, which rewrite the wire key before the lookup, so an explicit = "app_url" would be matched against the converted key and fail. swift/Sources/BasecampGenerator/ModelEmitter.swift:270 documents exactly that.
Todolist is joining an existing set, not inventing a shape: Wormhole, Folder, FolderWithProjects, SearchType, SearchResult, MyNote, Draft and TimelineEventData already emit this same block. It is a real generated-surface change, so it is called out rather than waved through as churn.
check-fixture-coverage now covers these fields — proven, not asserted
The guard null-checks only required fields. That is precisely why #628's mismatch — color published non-nullable while a manifest fixture carried "color": null — reached review instead of being caught. Making these required brings them under it.
Red proof. One mutated fixture tree (color key removed from todolist_groups/get.json, comments_app_url nulled in todolists/get.json), run against both specs via FIXTURE_DIR/FIXTURE_OPENAPI:
$ FIXTURE_OPENAPI=<openapi.json at origin/main> ruby scripts/check-fixture-coverage.rb
==> Fixture coverage clean — 20 covered schemas, 24 manifest targets, …
LANE630_NEG_BEFORE_EXIT_IS 0
$ FIXTURE_OPENAPI=<openapi.json on this branch> ruby scripts/check-fixture-coverage.rb
Fixture-coverage check failed:
- target `todolist-get`: todolists/get.json comments_app_url: required field is null but its schema is not nullable
- target `todolist-group-get`: todolist_groups/get.json missing required field `color`
LANE630_NEG_AFTER_EXIT_IS 1
Identical fixtures, exit 0 before and exit 1 after: the guard was blind to both keys and now is not.
The nullable half still behaves. spec/fixtures/todolist_groups/get.json carries a genuine "color": null and passes unmodified — required-and-nullable accepts the null it is supposed to accept, and rejects only the absence.
Fixture sweep — 22 failures, and no missing key in any captured body
The two runtime-strict SDKs failed as predicted; the four permissive ones stayed green throughout.
| SDK | before the sweep | why |
|---|---|---|
| Kotlin | 17 TodolistsServiceTest failures, MissingFieldException | kotlinx.serialization enforces required members |
| Swift | 22 failures across TodolistsServiceExtensionsTests + GeneratedServiceTests, DecodingError.keyNotFound: Key 'color' | Codable enforces them |
| Go | green (compile break only, fixed) | encoding/json is permissive |
| TypeScript / Python / Ruby | green | types only / TypedDict / attr_accessor |
Several Swift failures were tests asserting an unrelated failure mode (expected DecodingError.typeMismatch, got …keyNotFound) that never got far enough to see it — worth noting, since a shallow read of the log makes them look like new defects.
Each SDK's canonical body helper gains both keys rather than each call site patching them in, so omitting one now has to be deliberate. color is threaded as a parameter so the group variants carry an explicit JSON null: Kotlin takes raw JSON, Swift takes Any so NSNull() can spell the null a String? would have silently turned into an absent key. Seven synthetic mock bodies in conformance/tests/todolists_write.json carried neither key; todolists_read.json already carried both.
Fixing only what broke was not enough, and a reviewer caught that twice. AGENTS.md §"Every Changed Field/Path Requires" says every response stub for a changed path must carry a newly required field, and adds that the automated guard covers only the manifest'd shared fixtures — "one-off inline stubs remain the reviewer's responsibility." The permissive SDKs stayed green while holding bodies BC3 cannot produce. 4c36d7b94 and 5803e9c54 fix them: Ruby's seven minimal response hashes, Python's _todolist(), TypeScript's mockGroup and both elements of mockGroups. color is null on the group stubs, not omitted.
The second miss is worth naming: that pass searched for stubs by grepping type: "Todolist", and mockGroups does not carry type, so a marker-based search skipped it. The final enumeration is by route — every test touching /todosets/{id}/todolists.json, /todolists/{id} or /todolists/{id}/groups.json — which cannot miss a stub for lacking a field. Everything else is audited and complete: Go and the remaining Ruby/Python/TypeScript stubs derive from the shared fixtures, and Kotlin's TodolistGroupsServiceTest.groupBody already carried both, which is why it never failed. The other route matches are not Todolist bodies — /todolists/{id}/todos.json returns Todos, the "type": "Todolist" hits elsewhere are parent references (TodoParent, no color), and todosets.test.ts only holds a todolists_url string.
No captured body is missing either key. All six Todolist-shaped objects under spec/fixtures/ carry both — which is what #628's reading of the jbuilder predicted, and the finding this PR was told to stop and report did not materialise.
Verification
Full make check re-run at every head, SHA pinned on both sides of each run. At the final head:
$ cat /tmp/lane630/check6-exit.txt
LANE630_MAKECHECK5_EXIT_IS 0 # marker text is from the reused runner; the file is per-run
PRE_SHA: 5803e9c546de13f05eb34cad1924d5ce4c9f10b5
POST_SHA: 5803e9c546de13f05eb34cad1924d5ce4c9f10b5 # identical — nothing moved under the gate
worktree clean
==> All checks passed
Earlier heads, same shape: bbc5a2768 exit 0, 12b02cda8 exit 0, 4c36d7b94 exit 0, each with PRE_SHA == POST_SHA.
Selected lines from that run:
No drift detected. # go / kotlin / swift generated-drift gates
Tests 1393 passed (1393) # TypeScript
1358 runs, 30434 assertions, 0 failures, 0 errors # Ruby
Executed 353 tests, with 0 failures (0 unexpected)# Swift — ran, not SKIPped
1170 passed, 4 skipped # Python
Results: 168 passed / 179 passed / 178 passed … # conformance, six runners
==> Fixture coverage clean — 20 covered schemas, 24 manifest targets, …
Two caveats on that log, stated rather than glossed:
- Kotlin
jvmTestreportsUP-TO-DATEin this run — cache-hit, not execution evidence. Kotlin actually executed in a separate./gradlew --offline jvmTest(exit 0) after the fixture fix, and authoritatively in the CI Kotlin Tests job, green onbbc5a2768. - Swift is the gate that matters most here and it genuinely ran:
Executed 353 tests, plusswift-check-driftreportingNo drift detectedagainst the committed generated tree.
Branch is 1 commit behind origin/main (c95d81ceb), a Ruby comment-only change to schedules_extensions.rb — disjoint from every file here.
copilot-pull-request-reviewer errored on all five attempts ("Copilot encountered an error and was unable to review this pull request") — the known flake. Codex reviewed at every head and its three findings are addressed above; CI is green.