Skip to content

Conversation

@matifali
Copy link
Member

Problem

The Zed module's settings parsing was broken. The previous implementation used quote escaping:

SETTINGS_JSON='${replace(var.settings, "\"", "\\\"")}'

This produced invalid JSON like {\"theme\":\"dark\"} which jq could not parse because the backslash-escaped quotes are not valid JSON syntax.

Solution

Changed to use base64 encoding internally:

locals {
  settings_b64 = var.settings != "" ? base64encode(var.settings) : ""
}

# In the script:
SETTINGS_B64='${local.settings_b64}'
SETTINGS_JSON="$(echo -n "${SETTINGS_B64}" | base64 -d)"

User interface remains the same - users still provide plain JSON via jsonencode() or heredoc:

module "zed" {
  source   = "..."
  agent_id = coder_agent.main.id
  settings = jsonencode({
    theme    = "dark"
    fontSize = 14
  })
}

Testing

Added comprehensive tests:

Terraform tests (5):

  • URL generation (default, folder, agent_name)
  • Settings base64 encoding verification
  • Empty settings edge case

Container e2e tests (3):

  • Creates settings file with correct JSON (including special chars: quotes, backslashes, URLs)
  • Merges with existing settings via jq
  • Exits early with empty settings

Also fixed existing tests to use override_data for proper workspace mocking.

The previous implementation used quote escaping which produced invalid JSON:
  SETTINGS_JSON='{"theme":"dark"}'

This broke jq parsing because the escaped quotes are not valid JSON.

Changed to use base64 encoding internally:
  settings_b64 = base64encode(var.settings)
  SETTINGS_JSON="$(echo -n "${SETTINGS_B64}" | base64 -d)"

User interface remains the same - pass JSON via jsonencode() or heredoc.

Also added end-to-end container tests and fixed existing tests to use
override_data for workspace mocking.
@DevelopmentCats
Copy link
Contributor

@matifali can you update the module version as well for this?

@DevelopmentCats DevelopmentCats added the version:patch Add to PRs requiring a patch version upgrade label Dec 15, 2025
@github-actions

This comment was marked as outdated.

@DevelopmentCats
Copy link
Contributor

Ill load this up and verify in the meantime

@DevelopmentCats
Copy link
Contributor

@matifali Have you tested this by chance? When I run this it looks like the project settings are read from /home/coder/.zed/settings.json rather than /home/coder/.config/zed/settings.json

@matifali
Copy link
Member Author

@matifali Have you tested this by chance? When I run this it looks like the project settings are read from /home/coder/.zed/settings.json rather than /home/coder/.config/zed/settings.json

This could be an upstream bug: As per the docs, it should read from ~/.config/zed/settings.json on Linux. :/

@matifali matifali removed the version:patch Add to PRs requiring a patch version upgrade label Dec 16, 2025
@matifali matifali self-assigned this Dec 16, 2025
@matifali matifali added the version:patch Add to PRs requiring a patch version upgrade label Dec 16, 2025
@github-actions
Copy link
Contributor

❌ Version Bump Validation Failed

Bump Type: patch

Module versions need to be updated but haven't been bumped yet.

Required Actions:

  1. Run the version bump script locally: ./.github/scripts/version-bump.sh patch
  2. Commit the changes: git add . && git commit -m "chore: bump module versions (patch)"
  3. Push the changes: git push

Script Output:

🔍 Detecting modified modules...
Found modules:
registry/coder/modules/zed

📦 Processing: coder/zed
Found git tag: release/coder/zed/v1.1.3 (v1.1.3)
Current version: 1.1.3
New version: 1.1.4
Updating version references for coder/zed in registry/coder/modules/zed/README.md

🔧 Running formatter to ensure consistent formatting...

📋 Summary:
Bump Type: patch

Modules Updated:

- coder/zed: v1.1.3 → v1.1.4

READMEs Updated:

- coder/zed

✅ Version bump completed successfully!
📝 README files have been updated with new versions.

Next steps:
1. Review the changes: git diff
2. Commit the changes: git add . && git commit -m 'chore: bump module versions (patch)'
3. Push the changes: git push

Please update the module versions and push the changes to continue.

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

Labels

version:patch Add to PRs requiring a patch version upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants