bytebase/bytebase · error

missing Google Chat webhook key

Error message

missing Google Chat webhook key

What it means

Validation in validateGoogleChatURL: fires when the https URL has a valid /v1/spaces/{id}/messages path but lacks the required key query parameter, meaning it is not a genuine Google Chat webhook URL.

Source

Thrown at backend/plugin/webhook/validator.go:121

	}

	return errors.Errorf("webhook URL domain %q is not allowed for webhook type %s (allowed domains: %v)",
		hostname, webhookType, allowedDomainsForType)
}

func validateGoogleChatURL(u *url.URL) error {
	if u.Scheme != "https" {
		return errors.Errorf("invalid Google Chat URL scheme: %s (only https is allowed)", u.Scheme)
	}

	parts := strings.Split(u.Path, "/")
	if len(parts) != 5 || parts[1] != "v1" || parts[2] != "spaces" || parts[3] == "" || parts[4] != "messages" {
		return errors.Errorf("invalid Google Chat webhook path: %s", u.Path)
	}

	query := u.Query()
	if query.Get("key") == "" {
		return errors.Errorf("missing Google Chat webhook key")
	}
	if query.Get("token") == "" {
		return errors.Errorf("missing Google Chat webhook token")
	}

	return nil
}

// URLSupportsDirectMessage reports whether a webhook URL's endpoint form can
// carry a direct message to the users an event mentions, rather than only a
// post to the channel the URL names.
//
// The one form that cannot is a Microsoft Teams Power Automate workflow
// endpoint. teams.Post routes on the same fact at delivery time, and it decides
// the question before the URL does: a webhook with direct messages enabled and
// mentioned users sends them and returns, so the workflow post never happens.
// Enabling it on a Power Automate webhook therefore diverts the customer's
// notifications away from the flow they built, which is why the console hides

View on GitHub (pinned to 1870550677)

Solutions

  1. Re-copy the complete webhook URL including ?key=...&token=... from Google Chat's webhook configuration
  2. Verify nothing (proxy, log redaction, config template) strips query parameters
  3. If the key was truly lost, delete and recreate the webhook in Google Chat to get a fresh URL
  4. Add frontend validation checking for key and token params before submitting

Example fix

// before
url := "https://chat.googleapis.com/v1/spaces/AAAA/messages?token=t"
// after
url := "https://chat.googleapis.com/v1/spaces/AAAA/messages?key=k&token=t"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(raw)
if err != nil { return err }
if u.Query().Get("key") == "" {
	return errors.New("Google Chat webhook URL must include the key query parameter")
}

Type guard

func hasGoogleChatKey(raw string) bool {
	u, err := url.Parse(raw)
	return err == nil && u.Query().Get("key") != ""
}

Try / catch

if err := webhook.ValidateWebhookURL(raw, "googlechat"); err != nil {
	if strings.Contains(err.Error(), "missing Google Chat webhook key") {
		return fmt.Errorf("copy the full webhook URL including ?key=...")
	}
	return err
}

Prevention

When it happens

Trigger: The URL path parses as /v1/spaces/<id>/messages but query.Get("key") returns empty — the key= parameter was stripped during copy/paste, the URL was truncated at the token, or a sanitizer removed query parameters.

Common situations: Sharing the webhook URL through chat/email tools that trim query strings; pasting only the path portion; a config templating system URL-encoding or dropping &-separated params; partially redacted URLs from screenshots.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/974f646aba9daf68. Report an issue: GitHub.