fix(contacts): send required other-contact copy mask (#384) (thanks @rbansal42)
Some checks failed
ci / test (push) Has been cancelled
ci / worker (push) Has been cancelled
ci / windows (push) Has been cancelled
ci / darwin-cgo-build (push) Has been cancelled

This commit is contained in:
Peter Steinberger 2026-03-07 16:49:41 +00:00
parent c97165a249
commit 7571a34cfe
3 changed files with 14 additions and 1 deletions

View File

@ -16,6 +16,7 @@
- Timezone: embed the IANA timezone database so Windows builds can resolve calendar timezones correctly. (#388) — thanks @visionik.
- 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.
- Auth: keep Keep-only service-account fallback isolated to Keep commands so other Google services do not accidentally pick it up. (#414) — thanks @jgwesterlund.
- Contacts: send the required `copyMask` when deleting "other contacts", avoiding People API 400 errors. (#384) — thanks @rbansal42.
- Gmail: add a fetch delay in `watch serve` so History API reads don't race message indexing. (#397) — thanks @salmonumbrella.
- Gmail: allow Workspace-managed send-as aliases with empty verification status in `send` and `drafts create`. (#407) — thanks @salmonumbrella.
- Gmail: preserve the selected `--client` during `watch serve` push handling instead of falling back to the default client. (#411) — thanks @chrysb.

View File

@ -120,6 +120,16 @@ func TestContactsOtherDelete_Success_JSON(t *testing.T) {
svc, closeSrv := newPeopleService(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case strings.Contains(r.URL.Path, "otherContacts/") && strings.Contains(r.URL.Path, ":copyOtherContactToMyContactsGroup") && r.Method == http.MethodPost:
var req struct {
CopyMask string `json:"copyMask"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
t.Fatalf("decode request: %v", err)
}
if req.CopyMask != otherContactCopyMask {
t.Fatalf("expected copyMask %q, got %q", otherContactCopyMask, req.CopyMask)
}
// Mock CopyOtherContactToMyContactsGroup response
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]any{

View File

@ -420,6 +420,8 @@ type ContactsOtherDeleteCmd struct {
ResourceName string `arg:"" name:"resourceName" help:"Resource name (otherContacts/...)"`
}
const otherContactCopyMask = "names,phoneNumbers,emailAddresses,organizations,biographies,urls,addresses,birthdays,events,relations,userDefined"
func (c *ContactsOtherDeleteCmd) Run(ctx context.Context, flags *RootFlags) error {
u := ui.FromContext(ctx)
resourceName := strings.TrimSpace(c.ResourceName)
@ -452,7 +454,7 @@ func deleteOtherContact(ctx context.Context, account, resourceName string) error
&people.CopyOtherContactToMyContactsGroupRequest{
// CopyMask is required by the People API; omitting it causes a 400 "copyMask is required" error.
// See: https://developers.google.com/people/api/rest/v1/otherContacts/copyOtherContactToMyContactsGroup
CopyMask: "names,phoneNumbers,emailAddresses,organizations,biographies,urls,addresses,birthdays,events,relations,userDefined",
CopyMask: otherContactCopyMask,
},
).Do()
if err != nil {