{"record":{"id":"17179c3b4968d004","repo":"denoland/deno","slug":"err-missing-option","errorCode":"ERR_MISSING_OPTION","errorMessage":"At least one of the group, prime, or primeLength options is required","messagePattern":"At least one of the group, prime, or primeLength options is required","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/crypto/keygen.ts","lineNumber":602,"sourceCode":"        }\n\n        if (mode === kSync) {\n          return op_node_generate_dh_group_key(group);\n        } else {\n          return op_node_generate_dh_group_key_async(group);\n        }\n      }\n\n      if (prime != null) {\n        if (primeLength != null) {\n          throw new ERR_INCOMPATIBLE_OPTION_PAIR(\"prime\", \"primeLength\");\n        }\n\n        validateBuffer(prime, \"options.prime\");\n      } else if (primeLength != null) {\n        validateInt32(primeLength, \"options.primeLength\", 0);\n      } else {\n        throw new ERR_MISSING_OPTION(\n          \"At least one of the group, prime, or primeLength options\",\n        );\n      }\n\n      if (generator != null) {\n        validateInt32(generator, \"options.generator\", 0);\n      }\n\n      const g = generator == null ? 2 : generator;\n\n      if (mode === kSync) {\n        return op_node_generate_dh_key(prime, primeLength ?? 0, g);\n      } else {\n        return op_node_generate_dh_key_async(\n          prime,\n          primeLength ?? 0,\n          g,\n        );","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/crypto/keygen.ts#L584-L620","documentation":"generateKeyPair('dh', options) requires exactly one source of DH parameters: options.group (predefined MODP group), options.prime (custom prime buffer), or options.primeLength (size for a generated prime). If none is present, the polyfill throws ERR_MISSING_OPTION: 'At least one of the group, prime, or primeLength options is required'.","triggerScenarios":"crypto.generateKeyPair('dh', {}) — or an options object containing only auxiliary keys like generator/modulusLength-style extras, with all three parameter sources missing.","commonSituations":"Options assembled conditionally where every branch skips the parameters; typo'd key names ('primeLen', 'groupname'); passing the options object in the wrong argument position (e.g. into the callback slot); believing generator alone is enough.","solutions":["Add one of group, prime, or primeLength to the options object","Log or assert the options object right before the call during development","If options are built dynamically, default to group: 'modp14' or primeLength: 2048 when nothing else is set"],"exampleFix":"// before\ncrypto.generateKeyPair('dh', { generator: 2 });\n// after\ncrypto.generateKeyPair('dh', { group: 'modp14' });","handlingStrategy":"validation","validationCode":"if (dhOptions.group == null && dhOptions.prime == null && dhOptions.primeLength == null) {\n  dhOptions.primeLength = 2048; // or throw, per policy\n}\ncrypto.generateKeyPairSync('dh', dhOptions);","typeGuard":"function hasDhParameterSource(o) {\n  return o.group != null || o.prime != null || o.primeLength != null;\n}","tryCatchPattern":"try {\n  crypto.generateKeyPairSync('dh', opts);\n} catch (e) {\n  if (e.code === 'ERR_MISSING_OPTION' && e.message.includes('primeLength')) {\n    opts.group = 'modp14';\n    return crypto.generateKeyPairSync('dh', opts);\n  }\n  throw e;\n}","preventionTips":["Type DH options so at least one parameter source is required (discriminated union)","Unit-test option assembly code with empty inputs","Log the final options object at debug level before crypto calls"],"tags":["crypto","keygen","diffie-hellman","options","node-compat"],"backgroundTag":"missing-required-option","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}