{"record":{"id":"0be092dcc7dd0e57","repo":"apache/beam","slug":"error-while-populating-display-data-for-component-s-s","errorCode":null,"errorMessage":"Error while populating display data for component '%s': %s","messagePattern":"Error while populating display data for component '(.+?)': (.+?)","errorType":"exception","errorClass":"PopulateDisplayDataException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/display/DisplayData.java","lineNumber":792,"sourceCode":"\n      Path prevPath = latestPath;\n      Class<?> prevNs = latestNs;\n      latestPath = path;\n      latestNs = namespace;\n\n      try {\n        subComponent.populateDisplayData(this);\n      } catch (PopulateDisplayDataException e) {\n        // Don't re-wrap exceptions recursively.\n        throw e;\n      } catch (OutOfMemoryError oom) {\n        throw oom;\n      } catch (Throwable e) {\n        String msg =\n            String.format(\n                \"Error while populating display data for component '%s': %s\",\n                namespace.getName(), e.getMessage());\n        throw new PopulateDisplayDataException(msg, e);\n      }\n\n      latestPath = prevPath;\n      latestNs = prevNs;\n\n      return this;\n    }\n\n    /** Marker exception class for exceptions encountered while populating display data. */\n    private static class PopulateDisplayDataException extends RuntimeException {\n      PopulateDisplayDataException(String message, Throwable cause) {\n        super(message, cause);\n      }\n    }\n\n    @Override\n    public Builder add(ItemSpec<?> item) {\n      checkNotNull(item, \"Input display item cannot be null\");","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/display/DisplayData.java#L774-L810","documentation":"Beam throws this when a component's populateDisplayData(DisplayData.Builder) callback throws any Throwable. DisplayData is collected for pipeline introspection (UIs, monitoring), and Beam wraps the failure in PopulateDisplayDataException, naming the failing component namespace and its message, so pipeline construction surfaces which component had bad display-data logic.","triggerScenarios":"A Transform (PTransform/DoFn/etc.) implements populateDisplayData and throws inside it — e.g. dereferencing a null field, calling a getter that throws, or formatting logic that fails — while DisplayData.collect() walks the component tree.","commonSituations":"Custom transforms that compute display data from mutable/nullable state; SDK internal components after upgrades; display data code reading external config files that are missing at graph-construction time.","solutions":["Fix the exception thrown inside the component's populateDisplayData method (see the wrapped cause e).","Guard nullable fields with DisplayData.Builder methods that tolerate null, or use valueOf(..., null ok variants).","Wrap risky display-data computation in try/catch inside populateDisplayData and register a static string instead."],"exampleFix":"// before\npublic void populateDisplayData(DisplayData.Builder builder) {\n  builder.add(DisplayData.item(\"path\", config.getPath().toString())); // NPE if path null\n}\n// after\npublic void populateDisplayData(DisplayData.Builder builder) {\n  builder.add(DisplayData.item(\"path\", String.valueOf(config.getPath())));\n}","handlingStrategy":"try-catch","validationCode":"// Verify display data collection succeeds during pipeline construction/testing:\nDisplayData.from(myTransform); // throws PopulateDisplayDataException early if broken","typeGuard":"boolean hasSafeDisplayData(PTransform<?,?> t) {\n  try { DisplayData.from(t); return true; } catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n  DisplayData.from(transform);\n} catch (PopulateDisplayDataException e) {\n  LOG.error(\"Display data failed for component\", e.getCause());\n}","preventionTips":["Never dereference nullable fields directly in populateDisplayData","Use String.valueOf or null-tolerant DisplayData.item builders","Exercise DisplayData.from() in unit tests of custom transforms"],"tags":["java","apache-beam","display-data","pipeline-construction"],"backgroundTag":"internal-invariant-violation","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"}