{"record":{"id":"df5ae878fc79a89a","repo":"gradle/gradle","slug":"cannot-set-s-in-s-as-it-is-a-filtered-collec","errorCode":null,"errorMessage":"Cannot set '%s' in '%s' as it is a filtered collection","messagePattern":"Cannot set '(.+?)' in '(.+?)' as it is a filtered collection","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"platforms/core-configuration/domain-object-collections/src/main/java/org/gradle/api/internal/collections/FilteredIndexedElementSource.java","lineNumber":50,"sourceCode":"\n    @Override\n    public S get(int index) {\n        int nextIndex = 0;\n        for (T t : collection) {\n            S s = filter.filter(t);\n            if (s != null) {\n                if (nextIndex == index) {\n                    return s;\n                }\n                nextIndex++;\n            }\n        }\n        throw new IndexOutOfBoundsException();\n    }\n\n    @Override\n    public S set(int index, S element) {\n        throw new UnsupportedOperationException(String.format(\"Cannot set '%s' in '%s' as it is a filtered collection\", element, this));\n    }\n\n    @Override\n    public S remove(int index) {\n        throw new UnsupportedOperationException(String.format(\"Cannot remove element from '%s' as it is a filtered collection\", this));\n    }\n\n    @Override\n    public int indexOf(Object o) {\n        int nextIndex = 0;\n        for (T t : collection) {\n            S s = filter.filter(t);\n            if (s != null) {\n                if (s.equals(o)) {\n                    return nextIndex;\n                }\n                nextIndex++;\n            }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/core-configuration/domain-object-collections/src/main/java/org/gradle/api/internal/collections/FilteredIndexedElementSource.java#L32-L68","documentation":"shouldResolveConsistentlyWith(source) makes this configuration resolve against the source's resolved state so both see identical versions. assertThatConsistentResolutionIsPropertyConfigured requires the source to be resolvable (isCanBeResolved) and throws InvalidUserCodeException naming both configurations when it is not.","triggerScenarios":"configurations.testRuntimeClasspath.shouldResolveConsistentlyWith(configurations.implementation) where implementation is declarable-only; wiring a consumable configuration as the consistent-resolution source.","commonSituations":"Trying to keep test and main runtime classpaths version-consistent while pointing at a non-resolvable configuration; plugin code guessing a source configuration name.","solutions":["Point at a resolvable configuration such as runtimeClasspath or a configurations.resolvable(...) one","If the intended source is declarable, add a resolvable configuration extending it and use that","Validate source.isCanBeResolved() before wiring"],"exampleFix":"// before\nconfigurations {\n    testRuntimeClasspath.shouldResolveConsistentlyWith(configurations.implementation) // not resolvable\n}\n\n// after\nconfigurations {\n    testRuntimeClasspath.shouldResolveConsistentlyWith(configurations.runtimeClasspath)\n}","handlingStrategy":"validation","validationCode":"if (!source.isCanBeResolved()) {\n    throw new GradleException(\"${source.name} is not resolvable; use a resolvable source such as runtimeClasspath\")\n}\ntarget.shouldResolveConsistentlyWith(source)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember consistent-resolution sources must themselves be resolvable","Wire classpath to classpath (testRuntimeClasspath -> runtimeClasspath)","Centralize this wiring in a convention plugin where configuration roles are known"],"tags":["gradle","consistent-resolution","configuration-roles"],"backgroundTag":"gradle-consistent-resolution-misuse","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}