sindresorhus/got · error · Error

HTTPS option `${key}` does not exist

Error message

HTTPS option `${key}` does not exist

What it means

Thrown by the `https` setter when the `https` options object has a key that is not a recognized advanced HTTPS/TLS option. Valid keys include `rejectUnauthorized`, `checkServerIdentity`, `serverName`, `certificateAuthority`, `key`, `certificate`, `passphrase`, `pfx`, `alpnProtocols`, `ciphers`, `dhparam`, `signatureAlgorithms`, `minVersion`, `maxVersion`, `honorCipherOrder`, `tlsSessionLifetime`, `ecdhCurve`, `certificateRevocationLists`, `secureOptions`. Unknown keys are rejected so a typo'd TLS setting does not silently leave a connection insecure.

Source

Thrown at source/core/options.ts:3209

		assertAny('https.alpnProtocols', [is.array, is.undefined], value.alpnProtocols);
		assertAny('https.ciphers', [is.string, is.undefined], value.ciphers);
		assertAny('https.dhparam', [is.string, is.buffer, is.undefined], value.dhparam);
		assertAny('https.signatureAlgorithms', [is.string, is.undefined], value.signatureAlgorithms);
		assertAny('https.minVersion', [is.string, is.undefined], value.minVersion);
		assertAny('https.maxVersion', [is.string, is.undefined], value.maxVersion);
		assertAny('https.honorCipherOrder', [is.boolean, is.undefined], value.honorCipherOrder);
		assertAny('https.tlsSessionLifetime', [is.number, is.undefined], value.tlsSessionLifetime);
		assertAny('https.ecdhCurve', [is.string, is.undefined], value.ecdhCurve);
		assertAny('https.certificateRevocationLists', [is.string, is.buffer, is.array, is.undefined], value.certificateRevocationLists);
		assertAny('https.secureOptions', [is.number, is.undefined], value.secureOptions);

		for (const key of Object.keys(value)) {
			if (key === '__proto__') {
				continue;
			}

			if (!(key in this.#internals.https)) {
				throw new Error(`HTTPS option \`${key}\` does not exist`);
			}
		}

		if (this.#merging) {
			safeObjectAssign(this.#internals.https, value);
		} else {
			this.#internals.https = {...value};
		}
	}

	/**
	[Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data.

	To get a [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), you need to set `responseType` to `buffer` instead.
	Don't set this option to `null`.

	__Note__: This doesn't affect streams! Instead, you need to do `got.stream(...).setEncoding(encoding)`.

View on GitHub (pinned to e3924aa1e5)

Solutions

  1. Use only the documented `https.*` option names (e.g. `certificateAuthority` not `ca`).
  2. Carefully check the `${key}` spelling in the error message.
  3. After fixing, verify the TLS behavior actually changed (e.g. via a self-signed cert test) since these settings are security-sensitive.

Example fix

// before
await got(url, {https: {ca: pem, rejectUnauthroized: true}});
// after
await got(url, {https: {certificateAuthority: pem, rejectUnauthorized: true}});
Defensive patterns

Strategy: type-guard

Validate before calling

const validHttpsKeys = new Set(['rejectUnauthorized','checkServerIdentity','serverName','certificateAuthority','key','certificate','passphrase','pfx','alpnProtocols','ciphers','dhparam','signatureAlgorithms','minVersion','maxVersion','honorCipherOrder','tlsSessionLifetime','ecdhCurve','certificateRevocationLists','secureOptions']);
function validateHttps(https) {
  for (const k of Object.keys(https ?? {})) {
    if (!validHttpsKeys.has(k)) throw new Error(`Unknown https option: ${k}`);
  }
}

Type guard

import type {HttpsOptions} from 'got';
function isHttpsOptions(v: unknown): v is HttpsOptions {
  if (typeof v !== 'object' || v === null) return false;
  // Trust the shipped type; this guard primarily rules out non-objects.
  return true;
}

Prevention

When it happens

Trigger: Calling `got(url, {https: {rejectUnauthroized: false}})` (typo), `{https: {ca: ...}}` (use `certificateAuthority`), or any `https` key outside the documented TLS options.

Common situations: Using Node's `tls.connect`/axios shorthand names (`ca`, `cert`, `key` already taken but `rejectUnauthorized` misspelled); typos; security-relevant config where a silent miss is dangerous.

Related errors


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