Skip to content

Fix TodolistOrGroup union deserialization for Get/Update#179

Merged
jeremy merged 2 commits intomainfrom
bc-9676179286
Mar 15, 2026
Merged

Fix TodolistOrGroup union deserialization for Get/Update#179
jeremy merged 2 commits intomainfrom
bc-9676179286

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 15, 2026

Summary

  • Fix broken union deserialization in todolists and todolist groups Get() and Update() methods. The API returns flat JSON ({"id": 123, "type": "Todolist", ...}) but the generated AsTodolistOrGroup0/1() methods expect envelope-wrapped variants ({"todolist": {...}}), yielding zero-valued structs. Bypasses the union helpers by decoding resp.Body directly into the target generated type.
  • Add httptest service contract tests for all four affected call sites. Each test asserts request method, URL path, response field population (ID, Name, Parent, Bucket, Creator), and for Update also validates the JSON request body payload.

Go-only containment fix — no changes to the shared openapi.json.

Test plan

  • go test ./pkg/basecamp/... — 4 new service-level tests pass
  • go test ./... — full Go test suite passes
  • make check — all cross-SDK checks pass (Smithy, Go, TS, Ruby, Kotlin, Swift, conformance)

Summary by cubic

Fix union deserialization in todolists and todolist groups Get() and Update() by correctly parsing the flat JSON the API returns. Go-only fix; no changes to openapi.json.

  • Bug Fixes

    • Decode resp.Body into generated.Todolist and generated.TodolistGroup instead of using AsTodolistOrGroup0/1.
    • Applies to Get() and Update() in TodolistsService and TodolistGroupsService.
  • Tests

    • Added httptest contract tests for Get() and Update() in both services.
    • Tests assert HTTP method, path, key response fields, and request body for updates.

Written for commit d1a620b. Summary will update on new commits.

jeremy added 2 commits March 14, 2026 22:11
The API returns flat JSON ({"id": 123, "type": "Todolist", ...}) but the
generated AsTodolistOrGroup0/1() methods expect envelope-wrapped variants
({"todolist": {...}}), yielding zero-valued structs. Bypass the broken
union helpers by decoding resp.Body directly into the target generated
type (Todolist or TodolistGroup). Affects Get() and Update() in both
todolists and todolist_groups services.
Tests Get and Update for both TodolistsService and TodolistGroupsService
using httptest.NewServer. Each test asserts request method, path, response
field population, and (for Update) the JSON request body payload.
@jeremy jeremy requested a review from a team as a code owner March 15, 2026 05:12
Copilot AI review requested due to automatic review settings March 15, 2026 05:12
@github-actions github-actions bot added the go label Mar 15, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Go Basecamp SDK’s todolist and todolist group services to correctly decode responses from the polymorphic /todolists/:id endpoint (which returns flat JSON), and adds httptest-based contract tests to lock in the expected request/response behavior.

Changes:

  • Decode Get/Update responses by unmarshalling resp.Body into generated.Todolist / generated.TodolistGroup instead of using the union-envelope helpers.
  • Add httptest contract tests for TodolistsService.Get/Update and TodolistGroupsService.Get/Update.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
go/pkg/basecamp/todolists.go Switches Get/Update response decoding to unmarshal flat JSON from resp.Body.
go/pkg/basecamp/todolists_test.go Adds httptest contract tests validating paths, request bodies, and basic response mapping for todolists.
go/pkg/basecamp/todolist_groups.go Switches Get/Update response decoding to unmarshal flat JSON from resp.Body.
go/pkg/basecamp/todolist_groups_test.go Adds httptest contract tests validating paths, request bodies, and basic response mapping for todolist groups.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremy jeremy merged commit 004678c into main Mar 15, 2026
53 checks passed
@jeremy jeremy deleted the bc-9676179286 branch March 15, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants