Internal service error(500) http status code is return when NoSuchLabelException is thrown in case when label(git branch) is absent during resource request via ResourceController

For example: We want to get file from config service under path: foo-service/table/table-schema.yml Service is deployed with configuration: spring.cloud.config.label=feature-absent-branch,master Branch in git feature(_)absent-branch was deleted after merge

To find required fille/resource we are trying each label in order they are configured, so when request http:///foo-service/profile/feature(_)absent-branch/table/table-schema.yml is executed an 500 http error is returned instead of 404(NOT_FOUND) and after that we are stop trying other labels.

Is this intentional? Or it is a bug? From my perspective it should be 404

Comment From: ryanjbaxter

Can you provide a stack trace and maybe a git repo that we can use to reproduce this?

Comment From: vmotolyzhenko

Here demo to reproduce this error: resource-error-demo 2.zip

Comment From: ryanjbaxter

Can you please describe how to reproduce the problem with this sample?

Comment From: KarpenkoAlexander

@ryanjbaxter I've created tiny PR to fix this issue. https://github.com/spring-cloud/spring-cloud-config/pull/1944/files. The point is that resource controller didn't have handler for repository exceptions and in case git branch is not found client received 500 instead of 404 as it is for environment controller.