{"record":{"id":"a3ff600a2fd49ee7","repo":"apache/druid","slug":"failed-to-load-pod-template-file-for-s-at-s","errorCode":null,"errorMessage":"Failed to load pod template file for [%s] at [%s]","messagePattern":"Failed to load pod template file for \\[(.+?)\\] at \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/taskadapter/DynamicConfigPodTemplateSelector.java","lineNumber":115,"sourceCode":"  private PodTemplate loadPodTemplate(String key, Properties properties) throws IAE\n  {\n    String property = TASK_PROPERTY + key;\n    String podTemplateFile = properties.getProperty(property);\n    if (podTemplateFile == null) {\n      throw new IAE(\"Pod template file not specified for [%s]\", property);\n    }\n\n    try {\n      // Use Optional to assert unmarshal result is non-null.\n      Optional<PodTemplate> maybeTemplate = Optional.of(Serialization.unmarshal(\n          Files.newInputStream(new File(podTemplateFile).toPath()),\n          PodTemplate.class\n      ));\n\n      return maybeTemplate.get();\n    }\n    catch (Exception e) {\n      throw new IAE(e, \"Failed to load pod template file for [%s] at [%s]\", property, podTemplateFile);\n    }\n  }\n\n  @SuppressWarnings(\"ResultOfMethodCallIgnored\")\n  private void validateTemplateSupplier(Supplier<PodTemplate> templateSupplier) throws IAE\n  {\n    templateSupplier.get();\n  }\n\n  @Override\n  public Optional<PodTemplateWithName> getPodTemplateForTask(Task task)\n  {\n    String requested = task.getContextValue(DruidK8sConstants.TASK_CONTEXT_POD_TEMPLATE_SELECTION_KEY);\n\n    if (requested != null && effectiveConfig.isAllowTaskPodTemplateSelection()) {\n      Supplier<PodTemplate> supplier = podTemplates.get(requested);\n      if (supplier == null) {\n        throw new IAE(","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/taskadapter/DynamicConfigPodTemplateSelector.java#L97-L133","documentation":"Thrown by DynamicConfigPodTemplateSelector.loadPodTemplate when reading or unmarshalling the configured pod template file fails for any reason — the file cannot be opened/read, or its YAML/JSON content is not a valid Kubernetes PodTemplate. The original exception is attached as the cause and the message names both the config property and file path so the operator can locate the bad input.","triggerScenarios":"Files.newInputStream fails (missing file, permission denied, bad path) or Serialization.unmarshal to PodTemplate.class throws (invalid YAML/JSON syntax, wrong Kubernetes resource kind, unsupported fields) — any exception from the try block is wrapped into this IAE.","commonSituations":"Typo in the file path or file deleted after config was written; template copied from a Deployment/Pod spec rather than a valid PodTemplate shape; indentation/YAML syntax errors; the Overlord lacks filesystem read permission or the file is not mounted into the container.","solutions":["Inspect the wrapped cause in the stack trace to distinguish file-open failure from parse failure","Verify the file exists at the configured path and is readable inside the Overlord container (mount the file into the pod if containerized)","Validate the template file is syntactically valid YAML/JSON and deserializes as a PodTemplate (kubectl apply --dry-run=client or a local unmarshal check)","Fix the path in druid.indexer.runner.k8s.podTemplate.<key> if the file was moved"],"exampleFix":"// before\ndruid.indexer.runner.k8s.podTemplate.base=/etc/druid/k8s/base-tempalte.yaml  # typo, file missing\n\n// after\ndruid.indexer.runner.k8s.podTemplate.base=/etc/druid/k8s/base-template.yaml","handlingStrategy":"validation","validationCode":"String path = props.getProperty(\"druid.indexer.runner.k8s.podTemplate.\" + key);\nFile f = new File(path);\nif (!f.isFile() || !f.canRead()) {\n    throw new IllegalArgumentException(\"Pod template file unreadable: \" + f.getAbsolutePath());\n}\n// Optionally dry-run parse:\ntry (InputStream in = Files.newInputStream(f.toPath())) {\n    Serialization.unmarshal(in, PodTemplate.class);\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"Invalid pod template YAML at \" + path, e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount template files into the Overlord pod and verify with an init check","Keep template files in version control and validate YAML syntax in CI","Confirm templates deserialize as PodTemplate, not Deployment/Pod specs"],"tags":["kubernetes","pod-template","file-read","yaml"],"backgroundTag":"file-read-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}