goreleaser/goreleaser · error

could not serialize request: %w

Error message

could not serialize request: %w

What it means

Wrapped error in the MCP pipe's Publish: json.Marshal failed to serialize the assembled server model (packages, transports, repository) for the /v0/publish request. Like other marshal guards over config-derived structs, failure indicates structurally invalid content rather than a network problem.

Source

Thrown at internal/pipe/mcp/mcp.go:164

			return fmt.Errorf("could not apply templates: %w", err)
		}
		version := ctx.Version
		if pkg.RegistryType == "oci" {
			version = ""
		}
		server.Packages = append(server.Packages, model.Package{
			RegistryType: pkg.RegistryType,
			Identifier:   pkg.Identifier,
			Version:      version,
			Transport: model.Transport{
				Type: pkg.Transport.Type,
			},
		})
	}

	jsonData, err := json.Marshal(server)
	if err != nil {
		return fmt.Errorf("could not serialize request: %w", err)
	}

	publishURL := p.registry + "/v0/publish"

	return retryx.Do(ctx, ctx.Config.Retry, func() error {
		req, err := http.NewRequestWithContext(ctx, http.MethodPost, publishURL, bytes.NewReader(jsonData))
		if err != nil {
			return retryx.Unrecoverable(fmt.Errorf("could not create request: %w", err))
		}
		req.Header.Set("Content-Type", "application/json")
		req.Header.Set("Authorization", "Bearer "+token)

		resp, err := http.DefaultClient.Do(req)
		if err != nil {
			return retryx.HTTP(fmt.Errorf("could not send request: %w", err), resp)
		}
		defer resp.Body.Close()

View on GitHub (pinned to f5edd73956)

Solutions

  1. Practically unreachable: the server model serializes to JSON unless it holds unsupported types
  2. Check custom fields injected into the server model for non-marshalable values
  3. Simplify transports/packages config if custom values were added
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/pipe/mcp/mcp.go:164 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05). Data as JSON: /api/errors/0d99de3ee9d7b599. Report an issue: GitHub.