spring-cloud / spring-cloud/spring-cloud-config

Retrieving properties in YAML or JSON format returns manipulated, incorrect property keys

Open
#2,423 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
2k
Forks
1.3k
Avg merge
2d 59m
Merged PRs (30d)
16

Description

Describe the bug
If a client app, e.g. "TestApp" has a TestApp.properties file containing properties such as:

hub.server=my.favorite.server
hub.server.timeout.millis=30000

And you call `{CONFIG-SERVER-URL}/dev/TestApp-dev.json'

The response will be:

{
    "hub": {
        "server": "my.favorite.server",
        "timeout": {
            "server.millis": "30000"
        }
    }
}

The issue is that for the "TestApp.hub.server.timeout.millis" property, the "server" part of the path is in the wrong place. If you converted this back to properties it would be:

TestApp.hub.timeout.server.millis=30000

instead of the expected:

TestApp.hub.server.timeout.millis=30000

I would expect something like this, though I'm not 100% sure that this is the correct way to do it. It does pass an online JSON format validator (using JSONLint).

{
  "hub": {
    "server": "my.favorite.server",
    "server.timeout.millis": 30000
  }
}

It the answer is that this set of properties can not properly be represented as JSON, then the expected behavior would be that the config server throws an error. It should never manipulate the property keys this way.

Also note that the same issue happens with "yml" format. The response from {CONFIG-SERVER-URL}/dev/TestApp-dev.yml is:

hub:
  server: my.favorite.server
  timeout:
    server.millis: '30000'

Sample
I will attach or link to a project that demonstrates this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the /dev/TestApp-dev.json and /dev/TestApp-dev.yml responses with the shown properties. Trace the config server path that serializes dotted property keys into JSON or YAML, then add regression coverage for the hub.server.timeout.millis case. Done means keys are preserved in the correct order, or the server reports that the property set cannot be represented safely.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.