chenhg5/cc-connect · error

googlechat: create response missing message name

Error message

googlechat: create response missing message name

What it means

This error is thrown when the Google Chat API response to the create-message call decodes as JSON but the `name` field is empty. The message resource name (e.g. "spaces/AAA/messages/MMM") is required to build the PATCH URL used by UpdateMessage, so without it the library cannot hand back a usable preview handle. It is a defensive check that the API returned a well-formed message resource.

Source

Thrown at platform/googlechat/streaming.go:60

	resp, err := p.doRequest(req)
	if err != nil {
		return nil, fmt.Errorf("googlechat: send preview: %w", err)
	}
	defer func() {
		if err := resp.Body.Close(); err != nil {
			slog.Warn("googlechat: close preview response body", "error", err)
		}
	}()
	var msg struct {
		Name string `json:"name"`
	}
	if err := json.NewDecoder(resp.Body).Decode(&msg); err != nil {
		return nil, fmt.Errorf("googlechat: parse create response: %w", err)
	}
	// drain any bytes json.Decoder left unread so the connection is reusable
	_, _ = io.Copy(io.Discard, resp.Body)
	if msg.Name == "" {
		return nil, fmt.Errorf("googlechat: create response missing message name")
	}
	return &previewHandle{name: msg.Name}, nil
}

// buildUpdateRequest builds the PATCH URL and JSON body to update a message's text.
func buildUpdateRequest(msgName, content string) (string, []byte, error) {
	u := chatAPIBase + msgName + "?updateMask=text"
	b, err := json.Marshal(map[string]any{"text": content})
	if err != nil {
		return "", nil, fmt.Errorf("googlechat: marshal update body: %w", err)
	}
	return u, b, nil
}

// UpdateMessage patches the preview message text in place. The engine passes the
// handle returned by SendPreviewStart (not the reply context). Implements
// core.MessageUpdater.
func (p *Platform) UpdateMessage(ctx context.Context, handle any, content string) error {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify the response actually comes from the Google Chat API (correct chatAPIBase, no proxy substitution)
  2. Check the API error payload in the body — an auth or permission failure often returns JSON without a message resource
  3. Confirm the platform adapter version matches the current Google Chat API response schema (name field is required)
  4. Enable request/response logging for the chat API call and inspect the payload
Defensive patterns

Strategy: try-catch

Try / catch

handle, err := p.SendPreviewStart(ctx, rctx, initialText)
if err != nil {
    if strings.Contains(err.Error(), "missing message name") {
        slog.Warn("googlechat preview: API returned no message name; verify API schema and auth", "error", err)
    }
    return fmt.Errorf("start streaming preview: %w", err)
}

Prevention

When it happens

Trigger: SendPreviewStart decodes the response successfully but msg.Name == "" — the JSON body was valid yet lacked a "name" field (or it was empty), e.g. an unexpected success payload or an error-shaped JSON body sent with a misleading status code.

Common situations: Google Chat API version/behavior changes altering the response shape; a proxy returning a valid-JSON but non-message body; misconfigured auth causing an API error JSON (e.g. {"error":{...}}) to come back; custom chatAPIBase pointing at an endpoint that does not return message resources.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/9b2cc06f40a748a8. Report an issue: GitHub.