sindresorhus/got · error · Error

Unexpected end of Link header parameters: ${rawLinkParameter

Error message

Unexpected end of Link header parameters: ${rawLinkParameters.join(';')}

What it means

parse-link-header.ts:81: after extracting the `<reference>`, the parser expects at least one `;`-separated parameter (e.g. `rel="next"`). A bare `</path>` with no parameters violates RFC 8288 (a link without `rel` is meaningless) and Got refuses it rather than emitting a parameter-less entry.

Source

Thrown at source/core/parse-link-header.ts:81

	for (const item of items) {
		// https://tools.ietf.org/html/rfc5988#section-5
		const [rawUriReference, ...rawLinkParameters] = splitHeaderValue(item, ';') as [string, ...string[]];
		const trimmedUriReference = rawUriReference.trim();

		// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
		if (trimmedUriReference[0] !== '<' || trimmedUriReference.at(-1) !== '>') {
			throw new Error(`Invalid format of the Link header reference: ${trimmedUriReference}`);
		}

		const reference = trimmedUriReference.slice(1, -1);
		const parameters: Record<string, string> = {};

		if (reference.includes('<') || reference.includes('>')) {
			throw new Error(`Invalid format of the Link header reference: ${trimmedUriReference}`);
		}

		if (rawLinkParameters.length === 0) {
			throw new Error(`Unexpected end of Link header parameters: ${rawLinkParameters.join(';')}`);
		}

		for (const rawParameter of rawLinkParameters) {
			const trimmedRawParameter = rawParameter.trim();
			const center = trimmedRawParameter.indexOf('=');

			if (center === -1) {
				throw new Error(`Failed to parse Link header: ${link}`);
			}

			const name = trimmedRawParameter.slice(0, center).trim();
			const value = trimmedRawParameter.slice(center + 1).trim();

			parameters[name] = value;
		}

		parsed.push({
			reference,

View on GitHub (pinned to e3924aa1e5)

Solutions

  1. Ensure every `Link` entry includes at least a `rel` parameter, e.g. `</page2>; rel="next"`.
  2. If you control the server, validate emitted Link headers against RFC 8288 in tests.
  3. If the upstream is unfixable, disable Got's automatic link pagination for that endpoint.
  4. Log `response.headers.link` to confirm which entry is missing parameters.

Example fix

// before: upstream sends  Link: </page2>

// after: upstream sends   Link: </page2>; rel="next"
Defensive patterns

Strategy: validation

Validate before calling

function hasParameters(item) {
  return item.split(';').length > 1;
}
const ok = (response.headers.link ?? '').split(',').every(hasParameters);

Type guard

const linkItemHasParams = (s: string): boolean => s.split(';').length > 1;

Prevention

When it happens

Trigger: A `Link` header entry like `</page2>` with no trailing `; rel=...`. Triggered when iterating items in `parseLinkHeader`: `rawLinkParameters` is empty so the join is empty and the message reads `Unexpected end of Link header parameters:`.

Common situations: A server emitting only the URL portion of a link (typo or partial template); a debugging endpoint hand-crafting headers; truncation by a proxy that strips everything after the first `;`.

Related errors


AI-assisted analysis of sindresorhus/got@e3924aa1e5 (2026-08-03). Data as JSON: /data/errors/48c63c6fba32d6cd.json. Report an issue: GitHub.