{"record":{"id":"090162b7ca295d24","repo":"apache/beam","slug":"the-value-s-in-gcs-custom-audit-entries-exceeds-the-d","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":"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":280,"sourceCode":"    boolean exceedsEntryLimit() {\n      if (this.containsKey(CUSTOM_AUDIT_JOB_ENTRY_KEY)) {\n        return this.size() > MAX_ENTRIES;\n      }\n\n      return this.size() > MAX_ENTRIES - 1;\n    }\n\n    @Override\n    public @Nullable String put(String key, String value) {\n      if (key.length() > MAX_KEY_LENGTH) {\n        throw new IllegalArgumentException(\n            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;","sourceCodeStart":262,"sourceCodeEnd":298,"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#L262-L298","documentation":"Same bounded map as above: put() throws IllegalArgumentException when the value exceeds MAX_VALUE_LENGTH (30 chars), because these values are serialized into GCS request headers with strict size limits.","triggerScenarios":"Calling put(key, value) on GcsCustomAuditEntries with a value longer than MAX_VALUE_LENGTH.","commonSituations":"Putting full job names, URLs, or JSON blobs as audit values; concatenating identifiers without checking length.","solutions":["Shorten the value to fit MAX_VALUE_LENGTH (30 characters)","Truncate or hash long identifiers before storing","Split data across multiple entries within MAX_ENTRIES","Pre-validate value lengths when building the options map"],"exampleFix":"// before\nentries.put(\"run\", longJobName);\n// after\nentries.put(\"run\", longJobName.substring(0, 30));","handlingStrategy":"validation","validationCode":"void safePut(GcsOptions.GcsCustomAuditEntries entries, String key, String value) {\n  if (value.length() > 30) throw new IllegalArgumentException(\"audit value too long: \" + value);\n  entries.put(key, value);\n}","typeGuard":"boolean validAuditValue(String v) { return v != null && v.length() <= 30; }","tryCatchPattern":"try {\n  entries.put(key, value);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"exceeds the\") && e.getMessage().contains(\"value\")) {\n    entries.put(key, value.substring(0, 30));\n  } else throw e;\n}","preventionTips":["Keep custom audit values <= 30 characters","Hash or truncate long job/trace identifiers","Validate values at config-parsing time","Add tests for value length limits"],"tags":["gcp","gcs","validation","limit","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"}