Skip to content

Fix/code server settings parsing#1015

Open
djarbz wants to merge 7 commits into
coder:mainfrom
djarbz:fix/code-server-settings-parsing
Open

Fix/code server settings parsing#1015
djarbz wants to merge 7 commits into
coder:mainfrom
djarbz:fix/code-server-settings-parsing

Conversation

@djarbz

@djarbz djarbz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Issue:
When defining variables like "git.blame.editorDecoration.template" = "$${authorName}" within the machine_settings map, users were seeing empty strings (e.g., " () — ") rendered in their workspace settings.json.
This was caused by corrupted existing settings.json files or premature bash evaluation by external tools.
The module's previous run.sh script 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-server module'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:

  • Strict JSON Validation: The save_settings function now verifies that an existing settings.json file contains valid JSON using jq (or python3 as a fallback) before attempting any merges. If the file is invalid, it throws a clear error and halts, rather than failing silently.
  • Overwrite Flags: Added overwrite_settings and overwrite_machine_settings boolean variables (defaulting to false). When set to true, the script completely bypasses the merge logic and safely overwrites the file.
  • Debug Mode: Introduced a debug variable (defaulting to false) that dynamically enables set -x in the bash script to make future troubleshooting easier.
  • DRY & Formatting Refactor: Streamlined the jq and python3 logic within run.sh to 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/python3 refactor to ensure it is fail-safe and DRY as well as draft this PR message.

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/code-server
New version: v1.6.0
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant