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 and others added 2 commits December 16, 2025 14:41
Signed-off-by: Muhammad Atif Ali <me@matifali.dev>
@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
@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Dec 17, 2025

@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 The only reason that I question this, is that I used the button to open my ubuntu workspace in zed, and when I click

zed > Open Project Settings file

it opens directly to .zed/ settings.json

and the settings from this file that I wrote into it are not being applied.

@coder coder deleted a comment from github-actions bot Dec 17, 2025
@DevelopmentCats DevelopmentCats added version:patch Add to PRs requiring a patch version upgrade and removed version:patch Add to PRs requiring a patch version upgrade labels Dec 17, 2025
@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Dec 17, 2025

@matifali if this is working for you though it does what its supposed to so we are probably good here since this is either user error on my end or a bug on their end

@DevelopmentCats DevelopmentCats merged commit ef5a903 into main Dec 17, 2025
5 checks passed
@DevelopmentCats DevelopmentCats deleted the zed-settings branch December 17, 2025 22:17
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