Add options for ConfigFactory to handle customConfig properly#2588
Add options for ConfigFactory to handle customConfig properly#2588mkondratek merged 2 commits intomainfrom
Conversation
| val config = ConfigFactory.parseString(text).resolve() | ||
| val config = JsonParser.parseString(text).asJsonObject |
There was a problem hiding this comment.
ConfigFactory does not render json. The rendered config contained the comment with # instead of //. Using JsonParser fixes the problem.
There was a problem hiding this comment.
Other option would be adding .setComments(false) in the current code.
I thought Lightened Config was a bit more forgiving when parsing e.g. additional commas.
Maybe we can write simple test for that and check how those corner cases looks in case of both approaches?
95ac480 to
6264807
Compare
| val config = ConfigFactory.parseString(text).resolve() | ||
| var config = ConfigFactory.parseString(text).resolve() | ||
| additionalProperties.forEach { (key, value) -> | ||
| config.withValue(key, ConfigValueFactory.fromAnyRef(value)) |
There was a problem hiding this comment.
There was a bug 😄 configs are immutable
There was a problem hiding this comment.
Basically, we ignored "foldingRanges": "indentation-based" - how important for us is this option?
| parsed | ||
| .get("cody") | ||
| .asJsonObject | ||
| .get("experimental") | ||
| .asJsonObject | ||
| .get("foldingRanges") | ||
| .asString) |
There was a problem hiding this comment.
withValue adds the field as
"cody": {
"experimental": {
"foldingRanges": "indentation-based"
}
}
instead of
"cody.experimental.foldingRanges": "indentation-based"
Is it a problem? 🤔
There was a problem hiding this comment.
IMHO It is not, those are equivalent in VSC config.
Fixes https://linear.app/sourcegraph/issue/CODY-4264/a-comment-in-cody-settingsjson-breaks-cody-initialization-stuck-at. ## Test plan 1. Have the cody_settings.json like this: ``` { // other providers... "openctx.providers": { "https://gist.githubusercontent.com/thenamankumar/3708f084fb2abd57adafe7f14620bdf7/raw/e7c7059cb5b04f6feead002e7b3a90c5b1a4bb96/provider.js": true } } ``` 2. Cody should initialize
cherry pick #2588 - allowing more flexibility as we didn't inform the team when branch cut was Fixes https://linear.app/sourcegraph/issue/CODY-4264/a-comment-in-cody-settingsjson-breaks-cody-initialization-stuck-at. ## Test plan 1. Have the cody_settings.json like this: ``` { // other providers... "openctx.providers": { "https://gist.githubusercontent.com/thenamankumar/3708f084fb2abd57adafe7f14620bdf7/raw/e7c7059cb5b04f6feead002e7b3a90c5b1a4bb96/provider.js": true } } ``` 2. Cody should initialize ## Test plan <!-- All pull requests REQUIRE a test plan: https://sourcegraph.com/docs/dev/background-information/testing_principles Why does it matter? These test plans are there to demonstrate that are following industry standards which are important or critical for our customers. They might be read by customers or an auditor. There are meant be simple and easy to read. Simply explain what you did to ensure your changes are correct! Here are a non exhaustive list of test plan examples to help you: - Making changes on a given feature or component: - "Covered by existing tests" or "CI" for the shortest possible plan if there is zero ambiguity - "Added new tests" - "Manually tested" (if non trivial, share some output, logs, or screenshot) - Updating docs: - "previewed locally" - share a screenshot if you want to be thorough - Updating deps, that would typically fail immediately in CI if incorrect - "CI" - "locally tested" --> Co-authored-by: Mikołaj Kondratek <mik.kondratek@gmail.com>
Fixes https://linear.app/sourcegraph/issue/CODY-4264/a-comment-in-cody-settingsjson-breaks-cody-initialization-stuck-at.
Test plan