{"record":{"id":"a56c59cfb075662b","repo":"apache/beam","slug":"runtimeexception","errorCode":null,"errorMessage":"RuntimeException","messagePattern":"RuntimeException","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/fn/channel/SocketAddressFactory.java","lineNumber":49,"sourceCode":"  private static final String UNIX_DOMAIN_SOCKET_PREFIX = \"unix://\";\n\n  /** Parse a {@link SocketAddress} from the given string. */\n  public static SocketAddress createFrom(String value) {\n    if (value.startsWith(UNIX_DOMAIN_SOCKET_PREFIX)) {\n      // Unix Domain Socket address.\n      // Create the underlying file for the Unix Domain Socket.\n      String filePath = value.substring(UNIX_DOMAIN_SOCKET_PREFIX.length());\n      File file = new File(filePath);\n      if (!file.isAbsolute()) {\n        throw new IllegalArgumentException(\"File path must be absolute: \" + filePath);\n      }\n      try {\n        if (file.createNewFile()) {\n          // If this application created the file, delete it when the application exits.\n          file.deleteOnExit();\n        }\n      } catch (IOException ex) {\n        throw new RuntimeException(ex);\n      }\n      // Create the SocketAddress referencing the file.\n      return new DomainSocketAddress(file);\n    } else {\n      // Standard TCP/IP address.\n      HostAndPort hostAndPort = HostAndPort.fromString(value);\n      checkArgument(\n          hostAndPort.hasPort(),\n          \"Address must be a unix:// path or be in the form host:port. Got: %s\",\n          value);\n      return new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort());\n    }\n  }\n}\n","sourceCodeStart":31,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/channel/SocketAddressFactory.java#L31-L64","documentation":"When creating a unix domain socket address, SocketAddressFactory tries to create the underlying socket file eagerly (to register delete-on-exit). If File.createNewFile() fails with an IOException — e.g. missing directory, no write permission — it is wrapped in a RuntimeException.","triggerScenarios":"Configuring a unix socket endpoint whose parent directory does not exist or is not writable by the process (commonly the SDK harness or job server user in a container).","commonSituations":"Read-only container filesystems, non-root users lacking permission to /tmp or the configured socket directory, socket directory deleted between processes.","solutions":["Ensure the socket's parent directory exists and is writable by the process user (mkdir/chmod it).","Choose a writable absolute path such as /tmp/beam-<id>.sock for the unix socket endpoint.","Use a TCP endpoint instead if the filesystem is read-only or shared across containers."],"exampleFix":"// before\n--endpoint=unix:/var/run/beam.sock // /var/run not writable in container\n// after\nmkdir -p /tmp/beam-sockets\n--endpoint=unix:/tmp/beam-sockets/beam.sock","handlingStrategy":"validation","validationCode":"File f = new File(socketPath);\nif (!f.getParentFile().exists() || !f.getParentFile().canWrite())\n  throw new IllegalStateException(\"socket dir missing/unwritable: \" + f.getParent());","typeGuard":null,"tryCatchPattern":"try { addr = SocketAddressFactory.createFrom(endpoint); } catch (RuntimeException e) { /* inspect IOException cause: fix permissions or switch to TCP */ throw e; }","preventionTips":["Pre-create and chmod the socket directory before launching Beam services","Avoid read-only container filesystems for socket paths","Fall back to TCP endpoints in restricted environments"],"tags":["beam","unix-domain-socket","ioexception","permissions"],"backgroundTag":"file-open-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}