Fix/code server settings parsing#1015
Open
djarbz wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Issue:
When defining variables like
"git.blame.editorDecoration.template" = "$${authorName}"within themachine_settingsmap, users were seeing empty strings (e.g.," () — ") rendered in their workspacesettings.json.This was caused by corrupted existing
settings.jsonfiles or premature bash evaluation by external tools.The module's previous
run.shscript would fail to merge the JSON when encountering a corrupted file and silently fall back to keeping the broken file without throwing a clear error.Resolution:
This PR hardens the
code-servermodule's startup script to strictly validate JSON, fail safely, and ensure consistent formatting, while introducing new flags to give users more control over how settings are applied.Changes Made:
save_settingsfunction now verifies that an existingsettings.jsonfile contains valid JSON usingjq(orpython3as a fallback) before attempting any merges. If the file is invalid, it throws a clear error and halts, rather than failing silently.overwrite_settingsandoverwrite_machine_settingsboolean variables (defaulting tofalse). When set totrue, the script completely bypasses the merge logic and safely overwrites the file.debugvariable (defaulting tofalse) that dynamically enablesset -xin the bash script to make future troubleshooting easier.jqandpython3logic withinrun.shto minimize code duplication. The script now ensures that whether it creates, overwrites, or merges the settings, the resulting JSON is always cleanly formatted.Note: AI was utilized to assist in reviewing the bash script execution flow, diagnosing the interpolation failure, and optimizing the
jq/python3refactor to ensure it is fail-safe and DRY as well as draft this PR message.Type of Change
Module Information
Path:
registry/coder/modules/code-serverNew version:
v1.6.0Breaking change: [ ] Yes [x] No
Testing & Validation
bun test)bun fmt)Related Issues
None