Skip to content

Fix addressed fields to use comma-separated strings#31

Open
cpinto wants to merge 1 commit intobasecamp:mainfrom
cpinto:fix/addressed-fields-comma-separated
Open

Fix addressed fields to use comma-separated strings#31
cpinto wants to merge 1 commit intobasecamp:mainfrom
cpinto:fix/addressed-fields-comma-separated

Conversation

@cpinto
Copy link
Copy Markdown
Contributor

@cpinto cpinto commented Apr 7, 2026

Summary

  • CreateReply and Messages.Create were sending addressed fields (directly, copied, blindcopied) as JSON arrays instead of comma-separated strings, causing 422 errors or silent draft creation
  • Messages.Create originally used strings.Join correctly but was regressed in 495c2fb when CC/BCC support was added; CreateReply copied the broken pattern in c39876a
  • Fixed both methods to use strings.Join(addrs, ",") matching the OpenAPI MessageAddressed spec (type: string)
  • Fixed TestMessagesService_Create which was asserting the wrong type ([]any instead of string)
  • Added entry.addressed validation to TestEntriesService_CreateReply which had none

Fixes basecamp/hey-cli#66

Test plan

  • go build ./... compiles
  • go test ./pkg/hey/... passes (both fixed tests validate string types)
  • Manual: hey reply <thread-id> -m "test" sends without 422
  • Manual: hey compose --to a@b.com --cc c@d.com sends without 422

🤖 Generated with Claude Code


Summary by cubic

Fix addressed fields to send comma-separated strings for compose and reply, matching the API spec and preventing 422 errors or silent draft creation. Aligns behavior in both paths and resolves basecamp/hey-cli#66.

  • Bug Fixes
    • CreateReply and Messages.Create now send directly, copied, and blindcopied as comma-separated strings (via strings.Join), per OpenAPI MessageAddressed (type: string).
    • Tests updated: fix expected types in TestMessagesService_Create and add addressed validation in TestEntriesService_CreateReply.

Written for commit 6d33c63. Summary will update on new commits.

The HEY API expects addressed fields (directly, copied, blindcopied) as
comma-separated strings, but CreateReply and Messages.Create were sending
[]string slices which serialize as JSON arrays, causing 422 errors or
silent draft creation.

Messages.Create originally used strings.Join correctly but this was
regressed in 495c2fb when CC/BCC support was added. CreateReply copied
the broken pattern in c39876a.

Fixes basecamp/hey-cli#66

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 7, 2026 14:19
@github-actions github-actions bot added the bug Something isn't working label Apr 7, 2026
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

This PR fixes a bug where CreateReply and Messages.Create methods were sending recipient fields (directly, copied, blindcopied) as JSON arrays instead of comma-separated strings, which was causing API validation errors (422 responses). The fix updates both methods to use strings.Join() to properly format email addresses as comma-separated strings, and updates the corresponding tests to expect string types instead of arrays. Additional test coverage for the CreateReply method's addressed field is also added.

Changes:

  • Fixed Messages.Create() to use strings.Join() for recipient fields
  • Fixed Entries.CreateReply() to use strings.Join() for recipient fields
  • Updated test assertions in TestMessagesService_Create to expect strings instead of arrays
  • Added validation for recipient fields in TestEntriesService_CreateReply

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
go/pkg/hey/messages.go Added strings import and updated Create() method to format recipient addresses as comma-separated strings
go/pkg/hey/entries.go Added strings import and updated CreateReply() method to format recipient addresses as comma-separated strings
go/pkg/hey/services_test.go Updated test assertions to expect string types and added missing validation for addressed field in CreateReply test

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

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 3 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reply command sends addressed fields as JSON arrays instead of comma-separated strings, causing 422 or drafts

2 participants