{"record":{"id":"5d75eaf8d3223dbc","repo":"apache/beam","slug":"the-maximum-allowed-number-of-gcs-custom-audit-entries","errorCode":null,"errorMessage":"The maximum allowed number of GCS custom audit entries (including the default x-goo-custom-audit-job) is %d.","messagePattern":"The maximum allowed number of GCS custom audit entries \\(including the default x-goo-custom-audit-job\\) is (.+?)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcsOptions.java","lineNumber":292,"sourceCode":"            String.format(\n                \"The key '%s' in GCS custom audit entries exceeds the %d-character limit.\",\n                key, MAX_KEY_LENGTH));\n      }\n\n      if (value.length() > MAX_VALUE_LENGTH) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"The value '%s' in GCS custom audit entries exceeds the %d-character limit.\",\n                value, MAX_VALUE_LENGTH));\n      }\n\n      String prefix = CUSTOM_AUDIT_ENTRY_TMPL.substring(0, CUSTOM_AUDIT_ENTRY_TMPL.indexOf('%'));\n      String formattedKey =\n          key.startsWith(prefix) ? key : String.format(CUSTOM_AUDIT_ENTRY_TMPL, key);\n      String oldValue = super.put(formattedKey, value);\n\n      if (exceedsEntryLimit()) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"The maximum allowed number of GCS custom audit entries (including the default x-goo-custom-audit-job) is %d.\",\n                MAX_ENTRIES));\n      }\n\n      return oldValue;\n    }\n  }\n}\n\nclass GcsReadOptionsSerializer extends JsonSerializer<GoogleCloudStorageReadOptions> {\n  static final GoogleCloudStorageReadOptions DEFAULT_OPTIONS =\n      GoogleCloudStorageReadOptions.DEFAULT.toBuilder()\n          .setFadvise(GoogleCloudStorageReadOptions.Fadvise.SEQUENTIAL)\n          .build();\n\n  @Override\n  public void serialize(","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcsOptions.java#L274-L310","documentation":"GcsCustomAuditEntries allows at most MAX_ENTRIES audit entries (including the default x-goo-custom-audit-job); put() that pushes the map past the limit throws IllegalArgumentException with this message after the entry was inserted (the put is not rolled back).","triggerScenarios":"Adding more than MAX_ENTRIES - 1 custom entries via put(); exceedsEntryLimit() returns true after super.put(formattedKey, value).","commonSituations":"Automatically populating audit entries per-tenant/per-dimension without bounding the count; repeated pipeline configurations accumulating keys.","solutions":["Reduce the number of custom audit entries to stay within MAX_ENTRIES","Merge related dimensions into fewer, shorter entries","Drop low-value entries before put (check exceedsEntryLimit() yourself first)","Gate additions: if (entries.exceedsEntryLimit()) skip instead of adding"],"exampleFix":"// before\nfor (String k : manyKeys) entries.put(k, v); // exceeds limit\n// after\nint budget = MAX_ENTRIES - 1 - entries.size();\nfor (String k : manyKeys) { if (budget-- <= 0) break; entries.put(k, v); }","handlingStrategy":"validation","validationCode":"// check capacity before adding\nif (!entries.exceedsEntryLimit()) { /* safe to add one more */ entries.put(key, value); }","typeGuard":null,"tryCatchPattern":"try {\n  entries.put(key, value);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"maximum allowed number\")) {\n    // drop or merge an existing entry, then retry once\n  } else throw e;\n}","preventionTips":["Bound the number of audit entries you generate (MAX_ENTRIES includes the default one)","Merge related dimensions into fewer entries","Check size() before each put","Centralize audit-entry population in one audited helper"],"tags":["gcp","gcs","limit","validation","java"],"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-14T16:17:12.679Z"}