GoogleContainerTools/jib · error · IllegalArgumentException
jib.to.tags contains empty tag
Error message
jib.to.tags contains empty tag
What it means
After resolving tags, getTags validates that no tag string is empty and throws IllegalArgumentException if any element of jib.to.tags is the empty string. Empty tags are invalid image references and would fail later at reference parsing, so Jib fails fast at configuration time.
Source
Thrown at jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TargetImageParameters.java:85
this.image.set(image);
}
@Input
@Optional
public Set<String> getTags() {
String property = System.getProperty(PropertyNames.TO_TAGS);
Set<String> tagsValue;
if (property != null) {
tagsValue = ImmutableSet.copyOf(ConfigurationPropertyValidator.parseListProperty(property));
} else {
try {
tagsValue = tags.get();
} catch (NullPointerException ex) {
throw new IllegalArgumentException("jib.to.tags contains null tag");
}
}
if (tagsValue.stream().anyMatch(str -> str.isEmpty())) {
throw new IllegalArgumentException("jib.to.tags contains empty tag");
}
return tagsValue;
}
public void setTags(List<String> tags) {
this.tags.set(tags);
}
public void setTags(Set<String> tags) {
this.tags.set(tags);
}
public void setTags(Provider<Set<String>> tags) {
this.tags.set(tags);
}
@Nested
@OptionalView on GitHub (pinned to fb949e2676)
Solutions
- Filter out empty strings: tags.findAll { !it.isEmpty() } before assignment
- Give the CI variable a default: ${TAG:-latest} or Gradle equivalent
- Validate the variable is non-empty in the build script before composing jib.to.tags
- Correct the literal list to remove empty entries
Example fix
// before
jib.to.tags = ['latest', System.getenv('TAG') ?: ''] // empty when TAG unset
// after
jib.to.tags = ['latest', System.getenv('TAG')].findAll { it != null && !it.isEmpty() } Defensive patterns
Strategy: type-guard
Validate before calling
def rawTags = jib.to.tags.orNull ?: []
if (rawTags.any { !(it?.trim()) }) {
throw new GradleException('jib.to.tags must not contain empty tags')
} Type guard
static boolean allTagsNonEmpty(List<String> tags) {
tags != null && tags.every { it != null && !it.isEmpty() }
} Try / catch
try {
def tags = targetImageParameters.tags
} catch (IllegalArgumentException e) {
if (e.message.contains('empty tag')) {
logger.error('Remove empty strings from jib.to.tags; give CI vars defaults')
} else { throw e }
} Prevention
- Always provide defaults for interpolated tag variables: ${TAG:-latest}
- Filter blank entries: findAll { it?.trim() }
- Validate the resolved tag set in CI before running jib tasks
- Avoid building tag lists by string concatenation that can yield empty segments
When it happens
Trigger: Configuring `jib.to.tags = ['latest', '']` — e.g. an empty CI variable like TAG="" interpolated into the list — then calling getTags(); also jib.to.tags from a list property where an entry is blank.
Common situations: CI environment variables (git tag, build number) being empty and passed straight into jib.to.tags; trailing comma artifacts in list properties; user typo leaving an empty string literal in the list.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- container.appRoot is not an absolute Unix-style path: ${inva
- invalid value for containerizingMode: ${invalidContainerizin
- container.workingDirectory is not an absolute Unix-style pat
- from.platforms contains a platform configuration that is mis
- container.volumes is not an absolute Unix-style path: ${inva
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/b2bcc3d06eb690ff.
Report an issue: GitHub.