{"record":{"id":"642b358682c93990","repo":"GoogleContainerTools/jib","slug":"jib-to-tags-contains-null-tag","errorCode":null,"errorMessage":"jib.to.tags contains null tag","messagePattern":"jib\\.to\\.tags contains null 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":81,"sourceCode":"    this.image.set(image);\n  }\n\n  public void setImage(Provider<String> image) {\n    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);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TargetImageParameters.java#L63-L99","documentation":"TargetImageParameters.getTags resolves the set of tags for jib.to.tags. When no list property is configured, it calls tags.get(); a NullPointerException there means a null element was supplied to the tag set, so it is converted into an IllegalArgumentException stating that jib.to.tags contains a null tag.","triggerScenarios":"Configuring `jib.to.tags = ['latest', null]` (a list containing null), or calling setTags(List.asList(...null...)) / provider supplying a null element, then invoking getTags() during configuration resolution.","commonSituations":"Programmatically building the tag list from data where a missing tag becomes null; property interpolation producing null entries; tests or plugins assembling tag lists without filtering nulls.","solutions":["Remove null entries from the jib.to.tags list before building","Filter with a null-check: tags.findAll { it != null } when constructing the list","Fix the upstream source (property/env/CI variable) that injects a null value","Add a Gradle configuration guard that validates jib.to.tags in afterEvaluate"],"exampleFix":"// before\njib.to.tags = ['latest', System.getenv('BUILD_TAG')] // env may be null\n// after\njib.to.tags = ['latest', System.getenv('BUILD_TAG')].findAll { it != null }","handlingStrategy":"type-guard","validationCode":"def rawTags = jib.to.tags.orNull ?: []\nif (rawTags.any { it == null }) {\n  throw new GradleException('jib.to.tags must not contain null entries')\n}","typeGuard":"static boolean hasNoNullTags(List<String> tags) {\n  tags != null && tags.every { it != null }\n}","tryCatchPattern":"try {\n  def tags = targetImageParameters.tags\n} catch (IllegalArgumentException e) {\n  if (e.message.contains('null tag')) {\n    logger.error('Filter null entries from jib.to.tags before build')\n  } else { throw e }\n}","preventionTips":["Filter nulls when constructing tag lists from env/CI variables: findAll { it != null }","Never pass nullable variables directly into jib.to.tags","Validate configured tags in an afterEvaluate check task","Prefer explicit defaults ('latest') over nullable inputs"],"tags":["jib","gradle","null-value","configuration"],"backgroundTag":"null-argument","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"}