{"record":{"id":"f3d6a02dfc52d69b","repo":"gradle/gradle","slug":"version-cannot-be-null","errorCode":null,"errorMessage":"Version cannot be null","messagePattern":"Version cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/DefaultRepositoryContentDescriptor.java","lineNumber":134,"sourceCode":"        return copy;\n    }\n\n    @Nullable\n    private static ImmutableList<SpecMatcher> createSpecMatchers(@Nullable Set<ContentSpec> specs) {\n        ImmutableList<SpecMatcher> matchers = null;\n        if (specs != null) {\n            ImmutableList.Builder<SpecMatcher> builder = ImmutableList.builderWithExpectedSize(specs.size());\n            for (ContentSpec spec : specs) {\n                builder.add(spec.toMatcher());\n            }\n            matchers = builder.build();\n        }\n        return matchers;\n    }\n\n    private static void checkNotNull(@Nullable String value, String message) {\n        if (value == null) {\n            throw new IllegalArgumentException(message);\n        }\n    }\n\n    @Override\n    public void includeGroup(String group) {\n        checkNotNull(group, \"Group cannot be null\");\n        addInclude(group, null, null, MatcherKind.SIMPLE);\n    }\n\n    @Override\n    public void includeGroupAndSubgroups(String groupPrefix) {\n        checkNotNull(groupPrefix, \"Group prefix cannot be null\");\n        addInclude(groupPrefix, null, null, MatcherKind.SUB_GROUP);\n    }\n\n    @Override\n    public void includeGroupByRegex(String groupRegex) {\n        checkNotNull(groupRegex, \"Group regex cannot be null\");","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/DefaultRepositoryContentDescriptor.java#L116-L152","documentation":"Inside a repository content { } block, includeVersion(group, moduleName, version) (and excludeVersion) validate all three arguments; this message appears when version is null (group and module nulls fail earlier with their own messages). The version string (a selector such as 1.+ also works) is required to build the matcher, so Gradle throws IllegalArgumentException.","triggerScenarios":"content { includeVersion 'com.example', 'my-module', version } where the version variable or property is unset; reading the triple from a config map missing the version key.","commonSituations":"Pinning a repository to one version where the version comes from an optional gradle.properties entry; generated content filters where the version field was not populated; builds that intend 'any version' (use includeModule instead).","solutions":["Pass a concrete version or selector: includeVersion 'com.example', 'my-module', '1.0'","For 'any version of this module', use includeModule 'com.example', 'my-module' instead of a null version","Default or validate the value at the source before the content block runs"],"exampleFix":"// before\ncontent { includeVersion 'com.example', 'my-module', project.findProperty('pinnedVersion') } // null\n\n// after\ncontent { includeVersion 'com.example', 'my-module', (project.findProperty('pinnedVersion') ?: '1.0') }","handlingStrategy":"validation","validationCode":"def version = project.findProperty('pinnedVersion')\nif (version == null) throw new GradleException('pinnedVersion is required for includeVersion')\nrepositories { maven { content { includeVersion 'com.example', 'my-module', version } } }","typeGuard":"// Kotlin DSL\nfun requireVersion(value: String?): String =\n    checkNotNull(value) { \"Version cannot be null\" }","tryCatchPattern":null,"preventionTips":["Use includeModule for 'any version' instead of a null version","Treat version pins like other build inputs: validate them at configuration time","Prefer version selectors ('1.+') over hand-built strings from optional properties"],"tags":["gradle","repository-content-filter","null-check","dsl"],"backgroundTag":"null-argument","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}