temporalio/temporal · error

failed to encode link: %w

Error message

failed to encode link: %w

What it means

Error "failed to encode link: %w" thrown in temporalio/temporal.

Source

Thrown at common/nexus/nexusrpc/api.go:144

	return httpHeader
}

func addContextTimeoutToHTTPHeader(ctx context.Context, httpHeader http.Header) http.Header {
	deadline, ok := ctx.Deadline()
	if !ok {
		return httpHeader
	}
	httpHeader.Set(nexus.HeaderRequestTimeout, FormatDuration(time.Until(deadline)))
	return httpHeader
}

const linkTypeKey = "type"

// decodeLink encodes the link to Nexus-Link header value.
// It follows the same format of HTTP Link header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
func encodeLink(link nexus.Link) (string, error) {
	if err := validateLinkURL(link.URL); err != nil {
		return "", fmt.Errorf("failed to encode link: %w", err)
	}
	if err := validateLinkType(link.Type); err != nil {
		return "", fmt.Errorf("failed to encode link: %w", err)
	}
	return fmt.Sprintf(`<%s>; %s="%s"`, link.URL.String(), linkTypeKey, link.Type), nil
}

// decodeLink decodes the Nexus-Link header values.
// It must have the same format of HTTP Link header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
func decodeLink(encodedLink string) (nexus.Link, error) {
	var link nexus.Link
	encodedLink = strings.TrimSpace(encodedLink)
	if len(encodedLink) == 0 {
		return link, errors.New("failed to parse link header: value is empty")
	}

	if encodedLink[0] != '<' {
		return link, fmt.Errorf("failed to parse link header: invalid format: %s", encodedLink)

View on GitHub (pinned to bde624efd1)

When it happens

Trigger: Thrown at common/nexus/nexusrpc/api.go:144 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/ce351afc5e05c4d1. Report an issue: GitHub.