{"record":{"id":"6b33b541ce1b38f0","repo":"apache/beam","slug":"missing-required-parameter-s-for-gcphsmgeneratedsecret","errorCode":null,"errorMessage":"Missing required parameter(s) for GcpHsmGeneratedSecret: {sorted(list(missing))}","messagePattern":"Missing required parameter\\(s\\) for GcpHsmGeneratedSecret: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/utils/secret.py","lineNumber":319,"sourceCode":"  def __eq__(self, other: Any) -> bool:\n    if not isinstance(other, GcpHsmGeneratedSecret):\n      return False\n    return (\n        self._project_id == other._project_id and\n        self._location_id == other._location_id and\n        self._key_ring_id == other._key_ring_id and\n        self._key_id == other._key_id and\n        getattr(self, '_job_name', None) == getattr(other, '_job_name', None))\n\n  @classmethod\n  def from_dict(cls, spec_dict: Dict[str, str]) -> 'GcpHsmGeneratedSecret':\n    \"\"\"Initialize GcpHsmGeneratedSecret from a dictionary specification.\"\"\"\n    allowed_keys = {\n        'project_id', 'location_id', 'key_ring_id', 'key_id', 'job_name'\n    }\n    missing = allowed_keys - set(spec_dict.keys())\n    if missing:\n      raise ValueError(\n          f\"Missing required parameter(s) for GcpHsmGeneratedSecret: {sorted(list(missing))}\"\n      )\n    invalid_keys = set(spec_dict.keys()) - allowed_keys\n    if invalid_keys:\n      raise ValueError(\n          f\"Invalid secret parameter {', '.join(sorted(invalid_keys))}\")\n    return cls(\n        project_id=spec_dict['project_id'],\n        location_id=spec_dict['location_id'],\n        key_ring_id=spec_dict['key_ring_id'],\n        key_id=spec_dict['key_id'],\n        job_name=spec_dict['job_name'],\n    )\n\n  def get_secret_bytes(self) -> bytes:\n    \"\"\"Retrieves the secret bytes.\n\n    If the secret version already exists in Secret Manager, it is retrieved.","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/utils/secret.py#L301-L337","documentation":"GcpHsmGeneratedSecret.from_dict requires all of 'project_id', 'location_id', 'key_ring_id', 'key_id', 'job_name' in the spec dict. If any are missing, it raises this ValueError listing the missing keys.","triggerScenarios":"Calling GcpHsmGeneratedSecret.from_dict({'project_id': 'p', 'location_id': 'us', 'key_ring_id': 'ring'}) — omitting 'key_id' and/or 'job_name'; passing an empty dict.","commonSituations":"Partially filling the HSM spec because 'job_name' is easy to overlook; converting a plain GcpSecret spec to HSM without adding the KMS location/key-ring/key fields.","solutions":["Provide all five keys: project_id, location_id, key_ring_id, key_id, job_name.","Set job_name to your Beam job's name (it namespaces the derived secret).","Validate the dict against the required key set before calling from_dict."],"exampleFix":"// before\nGcpHsmGeneratedSecret.from_dict({'project_id': 'p', 'location_id': 'us', 'key_ring_id': 'r', 'key_id': 'k'})\n// after\nGcpHsmGeneratedSecret.from_dict({'project_id': 'p', 'location_id': 'us', 'key_ring_id': 'r', 'key_id': 'k', 'job_name': 'my-job'})","handlingStrategy":"validation","validationCode":"REQUIRED = {'project_id', 'location_id', 'key_ring_id', 'key_id', 'job_name'}\nmissing = REQUIRED - set(spec)\nif missing:\n    raise ValueError(f'HSM spec missing: {sorted(missing)}')","typeGuard":"def is_complete_hsm_spec(d) -> bool:\n    return isinstance(d, dict) and {'project_id', 'location_id', 'key_ring_id', 'key_id', 'job_name'} <= set(d)","tryCatchPattern":"try:\n    secret = GcpHsmGeneratedSecret.from_dict(spec)\nexcept ValueError as e:\n    raise ConfigError(f'incomplete HSM secret spec: {e}') from e\n","preventionTips":["Keep the HSM spec as a dataclass with all five required fields","Include job_name whenever constructing the spec","Validate specs at pipeline startup, not at secret-use time"],"tags":["python","apache-beam","hsm","kms","missing-field","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}