GoogleContainerTools/jib · error · RuntimeException

Bug in jib-core; please report the bug at <GitHub new issue

Error message

Bug in jib-core; please report the bug at <GitHub new issue URL>

What it means

While assembling the classpath string, toContainerBuilder iterates LayerType values and throws a RuntimeException for any unrecognized type, labelling it a jib-core bug. This is an internal invariant/default-case guard — hitting it means a new LayerType enum constant was added without updating this switch, which is not user-fixable.

Source

Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java:659

      // Construct entrypoint. Ensure classpath elements are in the same order as the files were
      // added to the JavaContainerBuilder.
      List<String> classpathElements = new ArrayList<>();
      for (LayerType path : classpathOrder) {
        switch (path) {
          case CLASSES:
            classpathElements.add(appRoot.resolve(classesDestination).toString());
            break;
          case RESOURCES:
            classpathElements.add(appRoot.resolve(resourcesDestination).toString());
            break;
          case DEPENDENCIES:
            classpathElements.add(appRoot.resolve(dependenciesDestination).resolve("*").toString());
            break;
          case EXTRA_FILES:
            classpathElements.add(appRoot.resolve(othersDestination).toString());
            break;
          default:
            throw new RuntimeException(
                "Bug in jib-core; please report the bug at " + ProjectInfo.GITHUB_NEW_ISSUE_URL);
        }
      }
      String classpathString = String.join(":", classpathElements);
      List<String> entrypoint = new ArrayList<>(4 + jvmFlags.size());
      entrypoint.add("java");
      entrypoint.addAll(jvmFlags);
      entrypoint.add("-cp");
      entrypoint.add(classpathString);
      entrypoint.add(mainClass);
      jibContainerBuilder.setEntrypoint(entrypoint);
    }

    return jibContainerBuilder;
  }

  private JavaContainerBuilder addDirectory(
      List<PathPredicatePair> addedPaths, Path directory, Predicate<Path> filter)

View on GitHub (pinned to fb949e2676)

Solutions

  1. Report the bug at the jib GitHub issue tracker as the message instructs, including the jib version
  2. Upgrade jib-core to the latest release where the switch covers all LayerType values
  3. Check that you are not mixing incompatible jib artifact versions (e.g. a different jib-core on the classpath)
  4. If using a fork, add a case for the new LayerType in toContainerBuilder

Example fix

// before
<use affected jib-core version>
// after
<upgrade>
// e.g. Maven:
<dependency>
  <groupId>com.google.cloud.tools</groupId>
  <artifactId>jib-core</artifactId>
  <version>0.27.2</version>
</dependency>
Defensive patterns

Strategy: try-catch

Try / catch

try { JibContainerBuilder b = builder.toContainerBuilder(); } catch (RuntimeException e) { if (e.getMessage().contains("Bug in jib-core")) { reportBug(e); } throw e; }

Prevention

When it happens

Trigger: Only reachable via an enum/switch inconsistency inside jib-core: a LayerType constant not handled by the switch in toContainerBuilder. Normal user code cannot trigger it through public APIs.

Common situations: Running a jib version with an internal bug, a patched/forked jib-core with a custom LayerType, or mixing mismatched jib artifact versions on the classpath.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/a7a846beaf36a1c9. Report an issue: GitHub.