Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.7.18</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure-processor</artifactId>
<version>2.7.18</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Comment on lines +124 to +129
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spring-boot-autoconfigure-processor is an annotation processor; however, the maven-compiler-plugin config in this POM uses annotationProcessorPaths and only lists Immutables. If you expect Spring’s autoconfigure metadata to be generated, add the processor to annotationProcessorPaths (or otherwise ensure it’s on the annotation processor path); otherwise this dependency is likely unused.

Suggested change
<artifactId>spring-boot-autoconfigure-processor</artifactId>
<version>2.7.18</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

Copilot uses AI. Check for mistakes.
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.18</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -173,7 +191,6 @@
<artifactId>opencensus-api</artifactId>
<version>${opencensus.version}</version>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
Expand Down Expand Up @@ -276,12 +293,6 @@
<version>${okhttp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.14.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*-
* -\-\-
* github-api
* --
* Copyright (C) 2016 - 2025 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.github.v3.spring;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

import com.spotify.github.v3.clients.GitHubClient;

@AutoConfiguration
@ConditionalOnClass(GitHubClient.class)
public class GithubClientAutoConfiguration {

@Bean
@ConditionalOnBean
public GitHubClient gitHubClient() {
Comment on lines +34 to +36
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ConditionalOnBean is used without specifying any bean types/names. In Spring Boot this condition is effectively ambiguous and can behave unexpectedly (or not match at all). If the intent is to only enable the bean when a specific dependency is present (e.g., ObjectMapper), specify that explicitly (or use @ConditionalOnClass / @ConditionalOnMissingBean as appropriate).

Copilot uses AI. Check for mistakes.
return GitHubClient.create(null, null);
Comment on lines +24 to +37
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This auto-configuration doesn’t match the PR goal (registering a GithubApiModule/Jackson Module). It currently creates a GitHubClient bean using GitHubClient.create(null, null), which leaves required constructor inputs (e.g., baseUrl/token) null and can lead to runtime failures when the client is used. Consider changing this configuration to expose a GithubApiModule bean (and only if Jackson is present, and if no user-defined module bean already exists) rather than instantiating a client with null parameters.

Suggested change
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import com.spotify.github.v3.clients.GitHubClient;
@AutoConfiguration
@ConditionalOnClass(GitHubClient.class)
public class GithubClientAutoConfiguration {
@Bean
@ConditionalOnBean
public GitHubClient gitHubClient() {
return GitHubClient.create(null, null);
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.spotify.github.v3.GithubApiModule;
import com.spotify.github.v3.clients.GitHubClient;
@AutoConfiguration
@ConditionalOnClass({GitHubClient.class, ObjectMapper.class, Module.class})
public class GithubClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean(Module.class)
public Module githubApiModule() {
return new GithubApiModule();

Copilot uses AI. Check for mistakes.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*-
* -\-\-
* github-api
* --
* Copyright (C) 2016 - 2025 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.github.v3.spring;

import org.junit.Test;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project’s existing tests use JUnit Jupiter (org.junit.jupiter.api.Test), but this new test uses JUnit 4 (org.junit.Test). This can cause the test not to run (or require vintage support) and is inconsistent with the repo’s current test framework.

Suggested change
import org.junit.Test;
import org.junit.jupiter.api.Test;

Copilot uses AI. Check for mistakes.
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.assertj.core.api.Assertions.assertThat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.spotify.github.jackson.GithubApiModule;

public class GithubClientAutoConfigurationTest {


private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(GithubClientAutoConfiguration.class));

@Test
public void testModuleIsRegistered(){

this.contextRunner
.withUserConfiguration(JacksonConfig.class)
.run((context) -> {
assertThat(context).hasSingleBean(GithubApiModule.class);
});
Comment on lines +39 to +45
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test asserts that a GithubApiModule bean is registered by GithubClientAutoConfiguration, but the auto-configuration currently defines a GitHubClient bean instead. As written, this test will fail unless some other configuration is providing GithubApiModule; align the test assertions with the actual auto-configured bean(s), or update the auto-configuration to register GithubApiModule as described in the PR.

Copilot uses AI. Check for mistakes.
}

@Test
public void testModuleIsNotRegisteredIfObjectMapperMissing(){

this.contextRunner
.run((context) -> {
assertThat(context).doesNotHaveBean(GithubApiModule.class);
});
}

@Configuration
static class JacksonConfig {

@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.spotify.github.v3.spring.GithubClientAutoConfiguration
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring Boot discovers auto-configurations from META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports in main resources. This file is currently under src/test/resources and uses META-INF/Spring (capital S), so it won’t be found in real applications (and may not be found on case-sensitive filesystems). Move it to src/main/resources/META-INF/spring/ with the correct casing to actually enable the auto-configuration.

Copilot uses AI. Check for mistakes.
Loading