{"record":{"id":"b2bcc3d06eb690ff","repo":"GoogleContainerTools/jib","slug":"jib-to-tags-contains-empty-tag","errorCode":null,"errorMessage":"jib.to.tags contains empty tag","messagePattern":"jib\\.to\\.tags contains empty tag","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TargetImageParameters.java","lineNumber":85,"sourceCode":"    this.image.set(image);\n  }\n\n  @Input\n  @Optional\n  public Set<String> getTags() {\n    String property = System.getProperty(PropertyNames.TO_TAGS);\n    Set<String> tagsValue;\n    if (property != null) {\n      tagsValue = ImmutableSet.copyOf(ConfigurationPropertyValidator.parseListProperty(property));\n    } else {\n      try {\n        tagsValue = tags.get();\n      } catch (NullPointerException ex) {\n        throw new IllegalArgumentException(\"jib.to.tags contains null tag\");\n      }\n    }\n    if (tagsValue.stream().anyMatch(str -> str.isEmpty())) {\n      throw new IllegalArgumentException(\"jib.to.tags contains empty tag\");\n    }\n    return tagsValue;\n  }\n\n  public void setTags(List<String> tags) {\n    this.tags.set(tags);\n  }\n\n  public void setTags(Set<String> tags) {\n    this.tags.set(tags);\n  }\n\n  public void setTags(Provider<Set<String>> tags) {\n    this.tags.set(tags);\n  }\n\n  @Nested\n  @Optional","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TargetImageParameters.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\njib.to.tags = ['latest', System.getenv('TAG') ?: ''] // empty when TAG unset\n// after\njib.to.tags = ['latest', System.getenv('TAG')].findAll { it != null && !it.isEmpty() }","handlingStrategy":"type-guard","validationCode":"def rawTags = jib.to.tags.orNull ?: []\nif (rawTags.any { !(it?.trim()) }) {\n  throw new GradleException('jib.to.tags must not contain empty tags')\n}","typeGuard":"static boolean allTagsNonEmpty(List<String> tags) {\n  tags != null && tags.every { it != null && !it.isEmpty() }\n}","tryCatchPattern":"try {\n  def tags = targetImageParameters.tags\n} catch (IllegalArgumentException e) {\n  if (e.message.contains('empty tag')) {\n    logger.error('Remove empty strings from jib.to.tags; give CI vars defaults')\n  } else { throw e }\n}","preventionTips":["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"],"tags":["jib","gradle","validation","configuration"],"backgroundTag":"empty-required-field","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}