I was validating a scenario where, if I provide a commit ID that is not present in the repository, the Config Client should use the second value from the property:
spring.cloud.config.label=${COMMIT_ID},${BRANCH}
Test 1
I passed the following commit ID from the Config Client to the Config Server:
COMMIT_ID=f7a5dafbe969da489f1282bc70f870a160a66c5f
In this case, the Config Server threw a RefNotFoundException, and the client then retried using the branch name. This behavior was expected.
Test 2
Next, I passed another non-existent commit ID:
COMMIT_ID=77a5dafbe969da489f1282bc70f870a160a66c5f
In this case, I received an IOException, and the Config Client failed to start.
So, even though both commit IDs are invalid and not present in the repository, they resulted in different exceptions — RefNotFoundException in one case and IOException in another.
Config Server Configuration
spring.cloud.config.server.git.uri=https://github.com/example-org/config-repo.git spring.cloud.config.server.git.username=your-username spring.cloud.config.server.git.password=your-password spring.cloud.config.server.git.search-paths=app1/ spring.cloud.config.server.default-label=development spring.cloud.config.server.git.basedir=/tmp/config-repo spring.cloud.config.server.git.clone-on-start=false spring.cloud.config.server.git.refresh-rate=0 spring.cloud.config.server.git.skipSslValidation=false spring.cloud.config.server.git.deleteUntrackedBranches=true spring.cloud.config.server.git.force-pull=true spring.cloud.config.server.git.pattern=
Config Client Configuration
spring.application.name=service spring.config.import=optional:configserver:${CONFIG_SERVER_URI} spring.cloud.config.fail-fast=true spring.cloud.config.label=${COMMIT_ID},${BRANCH}
spring.cloud.config.retry.max-attempts=5 spring.cloud.config.retry.max-interval=5000 spring.cloud.config.retry.initial-interval=2000 spring.cloud.config.retry.multiplier=1.5
Observation
Two different commit IDs that are both invalid led to different exception types:
RefNotFoundException— handled correctly, fallback to branch.IOException— caused client startup failure.
Why there are two behavior ?
Comment From: ryanjbaxter
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Comment From: jiten686
@ryanjbaxter It is just simple Application with following main class and build.gradle dependency
`@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
`
`ext {
set('springCloudVersion', "2023.0.3")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.cloud:spring-cloud-config-server'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
`
Comment From: jiten686
While debugging, it was observed that both exceptions are thrown from the resolve(String revstr) method in the org.eclipse.jgit.Repository class.