{"record":{"id":"77ebfde1431b9f53","repo":"chenhg5/cc-connect","slug":"googlechat-marshal-update-body-w","errorCode":null,"errorMessage":"googlechat: marshal update body: %w","messagePattern":"googlechat: marshal update body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"platform/googlechat/streaming.go","lineNumber":70,"sourceCode":"\t\tName string `json:\"name\"`\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(&msg); err != nil {\n\t\treturn nil, fmt.Errorf(\"googlechat: parse create response: %w\", err)\n\t}\n\t// drain any bytes json.Decoder left unread so the connection is reusable\n\t_, _ = io.Copy(io.Discard, resp.Body)\n\tif msg.Name == \"\" {\n\t\treturn nil, fmt.Errorf(\"googlechat: create response missing message name\")\n\t}\n\treturn &previewHandle{name: msg.Name}, nil\n}\n\n// buildUpdateRequest builds the PATCH URL and JSON body to update a message's text.\nfunc buildUpdateRequest(msgName, content string) (string, []byte, error) {\n\tu := chatAPIBase + msgName + \"?updateMask=text\"\n\tb, err := json.Marshal(map[string]any{\"text\": content})\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"googlechat: marshal update body: %w\", err)\n\t}\n\treturn u, b, nil\n}\n\n// UpdateMessage patches the preview message text in place. The engine passes the\n// handle returned by SendPreviewStart (not the reply context). Implements\n// core.MessageUpdater.\nfunc (p *Platform) UpdateMessage(ctx context.Context, handle any, content string) error {\n\th, ok := handle.(*previewHandle)\n\tif !ok {\n\t\treturn fmt.Errorf(\"googlechat: invalid preview handle type %T\", handle)\n\t}\n\turl, body, err := buildUpdateRequest(h.name, content)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPatch, url, bytes.NewReader(body))\n\tif err != nil {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/streaming.go#L52-L88","documentation":"This error wraps a json.Marshal failure while serializing the update body ({\"text\": content}) in buildUpdateRequest, which constructs the PATCH request for updating a streaming-preview message. json.Marshal of a map[string]any containing a single string value effectively cannot fail in practice, so this is a defensive branch. It is propagated verbatim from buildUpdateRequest to its callers (UpdateMessage and tests).","triggerScenarios":"json.Marshal(map[string]any{\"text\": content}) returns an error inside buildUpdateRequest. With the current body shape (one string value) this branch is practically unreachable; it would only trigger if the body construction were changed to include non-marshalable values (e.g. channels, funcs).","commonSituations":"Essentially none in production with the current code; developers modifying buildUpdateRequest to include unsupported value types would hit it. It may appear in test output when refactoring the function.","solutions":["No action needed at runtime — this branch is effectively dead with a string-only body","If you modified buildUpdateRequest, ensure all values in the body map are JSON-marshalable types","Check the wrapped error message for the offending value's type if the branch does fire"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    return fmt.Errorf(\"update preview message: %w\", err)\n}","preventionTips":["No runtime guard needed with the current string-only body","If extending buildUpdateRequest, keep all body values JSON-marshalable (no channels, funcs, or cyclic data)"],"tags":["googlechat","json","marshal","defensive"],"backgroundTag":"json-marshal-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}