You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(zed): fix settings JSON parsing with base64 encoding (#604)
## Problem
The Zed module's settings parsing was broken. The previous
implementation used quote escaping:
```hcl
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:
```hcl
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:
```hcl
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.
---------
Signed-off-by: Muhammad Atif Ali <me@matifali.dev>
Co-authored-by: DevCats <christofer@coder.com>
0 commit comments