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
- Ensure every `Link` entry includes at least a `rel` parameter, e.g. `</page2>; rel="next"`.
- If you control the server, validate emitted Link headers against RFC 8288 in tests.
- If the upstream is unfixable, disable Got's automatic link pagination for that endpoint.
- 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
- Ensure server-side Link entries always include `rel`.
- Validate emitted Link headers in server unit tests.
- Disable link pagination for endpoints that emit bare references.
- Log the raw Link header on parse failure.
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
- Invalid format of the Link header reference: ${trimmedUriRef
- Failed to parse Link header: ${link}
- Failed to parse Link header: ${value}
- `url` protocol must be followed by `//`
AI-assisted analysis of sindresorhus/got@e3924aa1e5 (2026-08-03).
Data as JSON: /data/errors/48c63c6fba32d6cd.json.
Report an issue: GitHub.