Steeltoe icon indicating copy to clipboard operation
Steeltoe copied to clipboard

Only the first label is being processed

Open thompson-tomo opened this issue 1 year ago • 2 comments

Describe the bug

When multiple labels are configured even though they are processed as part of a loop, only the first one will be called.

My App Settings is "Spring": { "Cloud": { "Config": { "Uri": "http://localhost:90/api/config", "Label": "General,FF" } } },

Steps to reproduce

Steps to reproduce the behavior:

  1. Setup the config provider
  2. Have payload returned
  3. Obseve no additional requests are made

Expected behavior

If i configure multiple labels, i expect the config to be fetched for each label

Environment (please complete the following information):

  • Steeltoe Version 3.2.6
  • Platform: Self-hosted
  • OS: Windows
  • .NET Version Net 8
  • Config is being returned using custom api which uses the steeltoe models.

Screenshots

Troublesome code for loop starts at: https://github.com/SteeltoeOSS/Steeltoe/blob/f4fe92f392f2d97b8882cecc2d6eb1293b6c2b96/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs#L310

Additional context or links

Add any other context about the problem here.

thompson-tomo avatar Apr 27 '24 05:04 thompson-tomo

Happy to tackle this once verified as a bug to be fixed in the v3 branch

thompson-tomo avatar Apr 27 '24 13:04 thompson-tomo

Interesting, it looks like there is already at least one test that should be testing this scenario. How are you adding Config Server to your app?

TimHess avatar Apr 29 '24 15:04 TimHess

So what i have is the following in my appsettings.json:

  "Spring": {
    "Application": {
      "Name": "Dashboard-SequenceEngine"
    },
    "Cloud": {
      "Config": {
        "Uri": "http://localhost:90/api/config",
        "Label": "General,FF"
      }
    }
  }

Looking at the code, what i can see is that upon a successful fetch of config via: https://github.com/SteeltoeOSS/Steeltoe/blob/f4fe92f392f2d97b8882cecc2d6eb1293b6c2b96/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs#L333 The loading function enters the if statement and forces a return on https://github.com/SteeltoeOSS/Steeltoe/blob/f4fe92f392f2d97b8882cecc2d6eb1293b6c2b96/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs#L382 without moving to the next tag and merging the config environments.

Hence it is only processing the first successful tag.

thompson-tomo avatar May 05 '24 22:05 thompson-tomo

OK, so after a little research to refresh my memory here, the initial response should have been that this is working as designed.

"Label" in this context is referring to a label for the backend repository, most commonly referring to a branch. More info in the Spring docs

Steeltoe supports multiple labels, but stops at the first one it finds since you probably don't want to config values from multiple branches. I suspect you want to use profiles rather than labels

TimHess avatar May 10 '24 15:05 TimHess

Thanks for that info @TimHess and upon me reading the link you shared, i can see that I was trying to misuse/didn't get the purpose of labels and as such i have submitted https://github.com/SteeltoeOSS/Documentation/pull/321 to improve the docs to make it clearer for others.

At the same time i also agree Profiles seem the correct approach. With that being said it appears that profiles don't have any function in the current client. To keep things clean let's discuss that in a seperate issue

thompson-tomo avatar May 11 '24 00:05 thompson-tomo