{"record":{"id":"a4e9da9ea2c5bcf4","repo":"apache/beam","slug":"the-value-s-in-gcs-custom-audit-entries-exceeds-the-d-a4e9da","errorCode":null,"errorMessage":"The value '%s' in GCS custom audit entries exceeds the %d-character limit.","messagePattern":"The value '(.+?)' in GCS custom audit entries exceeds the (.+?)-character limit\\.","errorType":"validation","errorClass":"argparse.ArgumentError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/options/pipeline_options.py","lineNumber":192,"sourceCode":"\n  def _exceed_entry_limit(self):\n    job_audit_entry = _GcsCustomAuditEntriesAction.GCS_AUDIT_PREFIX + 'job'\n    if job_audit_entry in self._custom_audit_entries:\n      return len(\n          self._custom_audit_entries) > _GcsCustomAuditEntriesAction.MAX_ENTRIES\n    else:\n      return len(self._custom_audit_entries) > (\n          _GcsCustomAuditEntriesAction.MAX_ENTRIES - 1)\n\n  def _add_entry(self, key, value):\n    if len(key) > _GcsCustomAuditEntriesAction.MAX_KEY_LENGTH:\n      raise argparse.ArgumentError(\n          None,\n          \"The key '%s' in GCS custom audit entries exceeds the %d-character limit.\"  # pylint: disable=line-too-long\n          % (key, _GcsCustomAuditEntriesAction.MAX_KEY_LENGTH))\n\n    if len(value) > _GcsCustomAuditEntriesAction.MAX_VALUE_LENGTH:\n      raise argparse.ArgumentError(\n          None,\n          \"The value '%s' in GCS custom audit entries exceeds the %d-character limit.\"  # pylint: disable=line-too-long\n          % (value, _GcsCustomAuditEntriesAction.MAX_VALUE_LENGTH))\n\n    if key.startswith(_GcsCustomAuditEntriesAction.GCS_AUDIT_PREFIX):\n      self._custom_audit_entries[key] = value\n    else:\n      self._custom_audit_entries[_GcsCustomAuditEntriesAction.GCS_AUDIT_PREFIX +\n                                 key] = value\n\n  def __call__(self, parser, namespace, values, option_string=None):\n    if not hasattr(namespace, self.dest) or getattr(namespace,\n                                                    self.dest) is None:\n      setattr(namespace, self.dest, {})\n      self._custom_audit_entries = getattr(namespace, self.dest)\n\n    if option_string == '--gcs_custom_audit_entries':\n      # in the format of {\"key\": \"value\"}","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/options/pipeline_options.py#L174-L210","documentation":"An argparse ArgumentError raised by the GCS custom audit entries option's _add_entry action: the value string supplied for a custom audit entry exceeds the maximum character length allowed per entry (MAX_KEY_LENGTH applies to keys, and this sibling guard applies to values). GCP enforces hard size limits on custom audit metadata, so the option rejects the value before it reaches the service.","triggerScenarios":"Passing a custom audit entry whose value string is longer than _GcsCustomAuditEntriesAction.MAX_VALUE_LENGTH, e.g. embedding a long JSON blob or URL as the value.","commonSituations":"Putting verbose context (stack traces, long descriptions, joined label sets) into audit values; building values programmatically from unbounded inputs.","solutions":["Shorten or truncate the audit value to fit MAX_VALUE_LENGTH","Move large payloads to GCS/a database and reference them with a short URL or ID in the audit value","Pre-validate value length in code before setting the pipeline option"],"exampleFix":"// before\n--gcs_custom_audit_entries=reason=<2000-char explanation>\n// after\n--gcs_custom_audit_entries=reason_id=run-12345","handlingStrategy":"validation","validationCode":"if len(value) > _GcsCustomAuditEntriesAction.MAX_VALUE_LENGTH:\n    value = value[:_GcsCustomAuditEntriesAction.MAX_VALUE_LENGTH]","typeGuard":"def is_valid_audit_value(value):\n    return isinstance(value, str) and len(value) <= 800","tryCatchPattern":"try:\n    parse_args(argv)\nexcept argparse.ArgumentError as ex:\n    print(f'audit value too long: {ex}')\n    sys.exit(2)","preventionTips":["Store large payloads externally and reference by ID","Pre-validate value length before setting options","Truncate programmatically built values"],"tags":["python","argparse","cli","gcs","audit"],"backgroundTag":"value-out-of-range","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"}