Fix addressed fields to use comma-separated strings#31
Open
cpinto wants to merge 1 commit intobasecamp:mainfrom
Open
Fix addressed fields to use comma-separated strings#31cpinto wants to merge 1 commit intobasecamp:mainfrom
cpinto wants to merge 1 commit intobasecamp:mainfrom
Conversation
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>
There was a problem hiding this comment.
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 usestrings.Join()for recipient fields - Fixed
Entries.CreateReply()to usestrings.Join()for recipient fields - Updated test assertions in
TestMessagesService_Createto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CreateReplyandMessages.Createwere sendingaddressedfields (directly,copied,blindcopied) as JSON arrays instead of comma-separated strings, causing 422 errors or silent draft creationMessages.Createoriginally usedstrings.Joincorrectly but was regressed in 495c2fb when CC/BCC support was added;CreateReplycopied the broken pattern in c39876astrings.Join(addrs, ",")matching the OpenAPIMessageAddressedspec (type: string)TestMessagesService_Createwhich was asserting the wrong type ([]anyinstead ofstring)entry.addressedvalidation toTestEntriesService_CreateReplywhich had noneFixes basecamp/hey-cli#66
Test plan
go build ./...compilesgo test ./pkg/hey/...passes (both fixed tests validate string types)hey reply <thread-id> -m "test"sends without 422hey compose --to a@b.com --cc c@d.comsends 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.
CreateReplyandMessages.Createnow senddirectly,copied, andblindcopiedas comma-separated strings (via strings.Join), per OpenAPIMessageAddressed(type: string).TestMessagesService_Createand addaddressedvalidation inTestEntriesService_CreateReply.Written for commit 6d33c63. Summary will update on new commits.