{"record":{"id":"80116faf146d9a8d","repo":"apache/beam","slug":"could-not-parse-the-provided-expansion-service-config-file","errorCode":null,"errorMessage":"Could not parse the provided Expansion Service config file","messagePattern":"Could not parse the provided Expansion Service config file","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/ExpansionServiceOptions.java","lineNumber":124,"sourceCode":"      return AllowList.nothing();\n    }\n  }\n\n  /** Loads the ExpansionService config. */\n  class ExpansionServiceConfigFactory implements DefaultValueFactory<ExpansionServiceConfig> {\n\n    @Override\n    public ExpansionServiceConfig create(PipelineOptions options) {\n      String configFile = options.as(ExpansionServiceOptions.class).getExpansionServiceConfigFile();\n      if (configFile != null) {\n        File configFileObj = new File(configFile);\n        if (!configFileObj.exists()) {\n          throw new IllegalArgumentException(\"Config file \" + configFile + \" does not exist\");\n        }\n        try (InputStream stream = new FileInputStream(configFileObj)) {\n          return ExpansionServiceConfig.parseFromYamlStream(stream);\n        } catch (FileNotFoundException e) {\n          throw new RuntimeException(\n              \"Could not parse the provided Expansion Service config file\" + configFile, e);\n        } catch (IOException e) {\n          throw new RuntimeException(\n              \"Could not parse the provided Expansion Service config file\" + configFile, e);\n        }\n      }\n\n      // By default produces null.\n      return ExpansionServiceConfig.empty();\n    }\n  }\n}\n","sourceCodeStart":106,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/ExpansionServiceOptions.java#L106-L137","documentation":"Wraps FileNotFoundException (or IOException) raised while opening/reading the expansion service config file in the config provider's create(). The message 'Could not parse the provided Expansion Service config file' plus path and cause replaces the raw IO exception with a contextual runtime exception.","triggerScenarios":"The config file disappears between the exists() check and open (delete race, broken symlink), or reading it fails due to permissions or IO problems.","commonSituations":"Config file managed by a symlink into a ConfigMap/secret that was rotated; permission changes after a container restart; TOCTOU races in deployment scripts.","solutions":["Confirm the file exists and is readable by the service user ('ls -lL', 'sudo -u svc cat <path>') and restart.","Replace broken symlinks with the real file path or fix the mount source.","Correct file permissions (chmod/chown) so the service process can read the config.","Inspect the wrapped cause for the underlying errno and address it (missing file vs permission denied)."],"exampleFix":"// before\nconfig -> /etc/expansion/current.yaml  (symlink to rotated-away file)\n// after\nls -lL /etc/expansion/current.yaml && java -jar expansion-service.jar --expansionServiceConfigFile=/etc/expansion/current.yaml","handlingStrategy":"try-catch","validationCode":"File f = new File(configPath);\nif (!f.isFile() || !f.canRead()) {\n  throw new IllegalStateException(\"Config file not readable (symlink/permissions?): \" + configPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  startExpansionService(options);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof FileNotFoundException || e.getCause() instanceof IOException) { /* fix file/mount and retry */ }\n  throw e;\n}","preventionTips":["Avoid symlink chains to rotated files; re-point mounts atomically.","Grant read access to the service user on the config directory.","Log and inspect the wrapped cause to distinguish missing-file from permission issues."],"tags":["java","file","io","config"],"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-20T03:17:13.778Z"}