Give Kotlin uploads.download and dispatch the download conformance family
Merged
JE
4mo ago+85+85+01234567890123456789-24-24-01234567890123456789
Closes the Kotlin download-capability gap (wave 1, rock B5): uploads.download(id) lands as a SPEC §18 composite over the existing downloadURL primitive, and the Kotlin conformance runner dispatches the DownloadURL/UploadsDownload family — five skips removed.
What changed
- Generator (
Config.kt):UploadsjoinsEXTENSIBLE_SERVICES(generated service becomesopen class) andHAND_WRITTEN_SERVICES(theaccount.uploadsaccessor constructs and declares the hand-written subclass). Regen diff is exactly the intended two files: theopen classkeyword inuploads.ktand the accessor rewire inServiceAccessors.kt— zero timestamp churn. - Composite (
services/UploadsService.kt, hand-written):download(uploadId)composes the public generatedget(GetUpload) with the client-leveldownloadURLprimitive (§14 authenticated hop 1, 302-follow, unauthenticated signed hop 2), throwsBasecampException.Usagewhen the upload has nodownload_url, and prefers the metadatafilenameover the URL-derived name — the TypeScriptuploads-extensions.tssemantics, delegation shape and all. Hooks observe the constituent operations (GetUpload, thenDownloadURL), never a synthetic composite. - Runner (
Main.kt):DownloadURLdispatch (syntheticstorage.3.basecamp.comhost + fixture path, rewritten to the mock origin by the SDK — same shape as the Go runner) andUploadsDownloaddispatch throughaccount.uploads.download. Also ports the missingheaderAbsentassertion (index-aware, present-but-empty fails, mirroring Go'sValuescheck) and givesheaderPresentthe schema'sindexsemantics — it previously always checked request 0, so per-hop auth assertions (auth'd hop 1, bare hop 2) could not be expressed. - Fixtures (
uploads_download.json): the two UploadsDownload metadata bodies grow from 3 sparse keys to the canonicalspec/fixtures/uploads/get.jsonshape; each test'sid/filename/download_urlsemantics are untouched (absolute storage URL in the delegate case,nullin the error case). Kotlin is the strictest consumer — kotlinx.serialization requires the model's non-optional fields — and the sparse bodies rode the runner's MissingFieldException→SKIP degradation path (the B6 flip target), which would have turned into hard failures later. Inline one-line style preserved: a 2-line diff. - SPEC: the five §19 Kotlin roster lines removed; the two remaining download-retry lines now carry the honest reason ("Kotlin download hop 1 does not retry yet (B4)"); §18's "Current composites" list gains the Uploads
downloadentry (already shipped in TS/Go/Python/Ruby, previously unlisted).
Verify-first findings
AccountClient.downloadURL(rawURL)already existed inDownload.ktwith the full two-hop flow: relative-Location resolution, "redirect $status with no Location header" (Api) on missing Location, direct-2xx path, bare unauthenticated hop 2. The gap was purely reachability: no composite, no dispatch.- The composite reaches the primitive by capturing its own
AccountClientreference (private val clientconstructor property) —BaseServicekeeps itsaccountClientprivate, so the TodosService/CardsService pattern alone (which only compose inherited methods) was not sufficient; verified against both precedents before writing. - Hop 2 shares the SDK engine (
HttpClient(httpClient.httpClient.engine)), so MockEngine serves both hops and the relative/signed/logo.pngLocation lands on the mock.
Red proof (pre-implementation, verbatim)
Five skips removed, before any implementation:
FAIL: DownloadURL auth'd first hop 302s to signed URL
Unexpected exception: UnsupportedOperationException: Unknown operation: DownloadURL
FAIL: DownloadURL direct 2xx body
Unexpected exception: UnsupportedOperationException: Unknown operation: DownloadURL
FAIL: DownloadURL surfaces redirect with no Location
Unexpected exception: UnsupportedOperationException: Unknown operation: DownloadURL
FAIL: UploadsDownload delegates through DownloadURL primitive
Unexpected exception: UnsupportedOperationException: Unknown operation: UploadsDownload
FAIL: UploadsDownload errors when upload has no download_url
Unexpected exception: UnsupportedOperationException: Unknown operation: UploadsDownload
Passed: 116, Failed: 5, Skipped: 3, Total: 124
Mid-implementation the suite also surfaced two real gaps, both fixed rather than worked around:
FAIL: DownloadURL auth'd first hop 302s to signed URL
Unknown assertion type: headerAbsent
SKIP: UploadsDownload delegates through DownloadURL primitive
Mock body lacks required Kotlin model fields: Fields [status, visible_to_clients, ...] are required for type ... 'com.basecamp.sdk.generated.models.Upload'
After
make conformance-kotlin:Passed: 121, Failed: 0, Skipped: 3, Total: 124(remaining: link-header architectural + the two B4 download-retry skips).- Cross-runner re-verification after the shared-fixture change: Go
122/0/2, Python122 passed, 0 failed, 2 skipped, Ruby106 passed, 0 failed, 18 skipped, TypeScript142 passed | 4 skipped. :basecamp-sdk:jvmTest: BUILD SUCCESSFUL.scripts/check-kotlin-generated-drift.sh: No drift detected.make conformance-fixtures-check: ok.
Summary by cubic
Adds uploads.download(id) to the Kotlin SDK by composing get with downloadURL. The Kotlin conformance runner now dispatches DownloadURL and UploadsDownload, removing five skips.
-
New Features
com.basecamp.sdk.services.UploadsService.download(uploadId)usesget+AccountClient.downloadURL, errors whendownload_urlis missing, and prefers the metadatafilename.- Generator marks
Uploadsas extensible and rewiresAccountClient.uploadstocom.basecamp.sdk.services.UploadsService. - Runner dispatches
DownloadURL(synthetic storage host) andUploadsDownloadviaaccount.uploads.download.
-
Bug Fixes
- Added
headerAbsentand fixedheaderPresentto honorindex, enabling per-hop auth assertions. - Expanded
uploads_download.jsonto the canonical upload shape so Kotlin models deserialize cleanly. - Updated
SPEC.mdto list the new composite and adjust Kotlin skip reasons (download hop 1 retry remains deferred).
- Added