Skip to content

Commit 7571a34

Browse files
committed
fix(contacts): send required other-contact copy mask (#384) (thanks @rbansal42)
1 parent c97165a commit 7571a34

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Timezone: embed the IANA timezone database so Windows builds can resolve calendar timezones correctly. (#388) — thanks @visionik.
1717
- Google API: use transport-level response-header timeouts for API clients while keeping token exchanges bounded, so large downloads are not cut short by `http.Client.Timeout`. (#425) — thanks @laihenyi.
1818
- Auth: keep Keep-only service-account fallback isolated to Keep commands so other Google services do not accidentally pick it up. (#414) — thanks @jgwesterlund.
19+
- Contacts: send the required `copyMask` when deleting "other contacts", avoiding People API 400 errors. (#384) — thanks @rbansal42.
1920
- Gmail: add a fetch delay in `watch serve` so History API reads don't race message indexing. (#397) — thanks @salmonumbrella.
2021
- Gmail: allow Workspace-managed send-as aliases with empty verification status in `send` and `drafts create`. (#407) — thanks @salmonumbrella.
2122
- Gmail: preserve the selected `--client` during `watch serve` push handling instead of falling back to the default client. (#411) — thanks @chrysb.

internal/cmd/contacts_crud_error_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ func TestContactsOtherDelete_Success_JSON(t *testing.T) {
120120
svc, closeSrv := newPeopleService(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
121121
switch {
122122
case strings.Contains(r.URL.Path, "otherContacts/") && strings.Contains(r.URL.Path, ":copyOtherContactToMyContactsGroup") && r.Method == http.MethodPost:
123+
var req struct {
124+
CopyMask string `json:"copyMask"`
125+
}
126+
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
127+
t.Fatalf("decode request: %v", err)
128+
}
129+
if req.CopyMask != otherContactCopyMask {
130+
t.Fatalf("expected copyMask %q, got %q", otherContactCopyMask, req.CopyMask)
131+
}
132+
123133
// Mock CopyOtherContactToMyContactsGroup response
124134
w.Header().Set("Content-Type", "application/json")
125135
_ = json.NewEncoder(w).Encode(map[string]any{

internal/cmd/contacts_directory.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ type ContactsOtherDeleteCmd struct {
420420
ResourceName string `arg:"" name:"resourceName" help:"Resource name (otherContacts/...)"`
421421
}
422422

423+
const otherContactCopyMask = "names,phoneNumbers,emailAddresses,organizations,biographies,urls,addresses,birthdays,events,relations,userDefined"
424+
423425
func (c *ContactsOtherDeleteCmd) Run(ctx context.Context, flags *RootFlags) error {
424426
u := ui.FromContext(ctx)
425427
resourceName := strings.TrimSpace(c.ResourceName)
@@ -452,7 +454,7 @@ func deleteOtherContact(ctx context.Context, account, resourceName string) error
452454
&people.CopyOtherContactToMyContactsGroupRequest{
453455
// CopyMask is required by the People API; omitting it causes a 400 "copyMask is required" error.
454456
// See: https://developers.google.com/people/api/rest/v1/otherContacts/copyOtherContactToMyContactsGroup
455-
CopyMask: "names,phoneNumbers,emailAddresses,organizations,biographies,urls,addresses,birthdays,events,relations,userDefined",
457+
CopyMask: otherContactCopyMask,
456458
},
457459
).Do()
458460
if err != nil {

0 commit comments

Comments
 (0)