From 0dd258e037f21d4d7287f695eeed459add0afb0a Mon Sep 17 00:00:00 2001 From: Andrew Aquino Date: Fri, 25 Sep 2026 19:00:30 +0000 Subject: [PATCH 1/2] fix: remove "dir breaks Coder Desktop file sync" warning The coder_agent.dir plan/apply-time warning claimed that setting dir to a value other than $HOME breaks Coder Desktop file sync. That is no longer accurate now that the Mutagen fix (coder/mutagen#10) is released and bundled into the macOS and Windows Desktop clients, which resolve the agent's absolute home directory and use it for both the scp copy and the ssh exec. Remove the file-sync sentence from WarnDirNotHome and from the dir field description, and regenerate docs. The dir deprecation itself is unchanged and still steers users to $HOME, so no min-version/adoption gate is needed. Tracked in DESK-2. Opened by Coder Agents on behalf of @aqandrew. --- docs/resources/agent.md | 2 +- provider/agent.go | 4 +--- provider/helpers/validation.go | 5 ++--- provider/helpers/validation_test.go | 6 +++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index d12146c2..fdba1883 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -77,7 +77,7 @@ resource "kubernetes_pod" "dev" { - `connection_timeout` (Number) Time in seconds until the agent is marked as timed out when a connection with the server cannot be established. A value of zero never marks the agent as timed out. - `dir` (String, Deprecated) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. -~> **Warning:** This attribute is deprecated and will be removed in a future release. Setting `dir` to a value other than `$HOME` will break [Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync). +~> **Warning:** This attribute is deprecated and will be removed in a future release. - `display_apps` (Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see [below for nested schema](#nestedblock--display_apps)) - `env` (Map of String) A mapping of environment variables to set inside the workspace. - `metadata` (Block List) Each `metadata` block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see [below for nested schema](#nestedblock--metadata)) diff --git a/provider/agent.go b/provider/agent.go index dc662e4a..356912fd 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -118,9 +118,7 @@ func agentResource() *schema.Resource { Optional: true, Deprecated: "dir has been deprecated and will be removed in a future release.", Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`." + - "\n\n~> **Warning:** This attribute is deprecated and will be removed in a future release. " + - "Setting `dir` to a value other than `$HOME` will break " + - "[Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync).", + "\n\n~> **Warning:** This attribute is deprecated and will be removed in a future release.", ValidateFunc: helpers.WarnDirNotHome, }, diff --git a/provider/helpers/validation.go b/provider/helpers/validation.go index 0167877a..ce13257e 100644 --- a/provider/helpers/validation.go +++ b/provider/helpers/validation.go @@ -22,8 +22,8 @@ func ValidateURL(value any, label string) ([]string, []error) { } // WarnDirNotHome returns a warning if dir is set to a value other -// than $HOME, because this breaks Coder Desktop file sync. The dir -// attribute is deprecated and will be removed in a future release. +// than $HOME. The dir attribute is deprecated and will be removed in +// a future release. func WarnDirNotHome(val interface{}, _ string) ([]string, []error) { d, ok := val.(string) if !ok || d == "" || d == "$HOME" || d == "~" { @@ -31,7 +31,6 @@ func WarnDirNotHome(val interface{}, _ string) ([]string, []error) { } return []string{ `"dir" is deprecated and will be removed in a future release.`, - `Setting "dir" to a value other than $HOME will break Coder Desktop file sync.`, }, nil } diff --git a/provider/helpers/validation_test.go b/provider/helpers/validation_test.go index 41ac35e1..79208fbc 100644 --- a/provider/helpers/validation_test.go +++ b/provider/helpers/validation_test.go @@ -181,17 +181,17 @@ func TestWarnDirNotHome(t *testing.T) { { name: "absolute path", value: "/workspace", - warnCount: 2, + warnCount: 1, }, { name: "relative path", value: "projects/foo", - warnCount: 2, + warnCount: 1, }, { name: "tilde subdir", value: "~/projects", - warnCount: 2, + warnCount: 1, }, } From 296d3a9da852a3cf6833eaabcbf2fd4e55041648 Mon Sep 17 00:00:00 2001 From: Andrew Aquino Date: Mon, 5 Oct 2026 20:37:58 +0000 Subject: [PATCH 2/2] fix: un-deprecate coder_agent dir The dir deprecation, its description warning, and the WarnDirNotHome plan-time validator were all added in #507 (DEVEX-227) solely because a non-$HOME dir broke Coder Desktop file sync. That is fixed in coder/mutagen#10, released and bundled into the macOS and Windows Desktop clients, so the deprecation no longer has a reason to exist. Atif, Asher, and Sushant confirmed on #549 that file sync was the only reason. Revert #507: drop the Deprecated field, the description warning, the ValidateFunc, WarnDirNotHome, and its test, and regenerate docs. Replace the warning with a short note that SFTP and scp resolve relative and ~/-prefixed paths against dir, so absolute paths should be used for file transfers (OpenSSH scp strips ~/ client-side). Opened by Coder Agents on behalf of @aqandrew. --- docs/resources/agent.md | 4 +-- provider/agent.go | 28 +++++++-------- provider/helpers/validation.go | 13 ------- provider/helpers/validation_test.go | 54 ----------------------------- 4 files changed, 13 insertions(+), 86 deletions(-) diff --git a/docs/resources/agent.md b/docs/resources/agent.md index fdba1883..ee474548 100644 --- a/docs/resources/agent.md +++ b/docs/resources/agent.md @@ -75,9 +75,7 @@ resource "kubernetes_pod" "dev" { - `api_key_scope` (String) Controls what API routes the agent token can access. Options: `all` (full access) or `no_user_data` (blocks `/external-auth`, `/gitsshkey`, and `/gitauth` routes) - `auth` (String) The authentication type the agent will use. Must be one of: `"token"`, `"google-instance-identity"`, `"aws-instance-identity"`, `"azure-instance-identity"`. - `connection_timeout` (Number) Time in seconds until the agent is marked as timed out when a connection with the server cannot be established. A value of zero never marks the agent as timed out. -- `dir` (String, Deprecated) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. - -~> **Warning:** This attribute is deprecated and will be removed in a future release. +- `dir` (String) The starting directory when a user creates a shell session. Defaults to `"$HOME"`. SFTP and scp resolve relative and `~/`-prefixed paths against this directory, so use absolute paths for file transfers. - `display_apps` (Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see [below for nested schema](#nestedblock--display_apps)) - `env` (Map of String) A mapping of environment variables to set inside the workspace. - `metadata` (Block List) Each `metadata` block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see [below for nested schema](#nestedblock--metadata)) diff --git a/provider/agent.go b/provider/agent.go index 356912fd..ff117bb9 100644 --- a/provider/agent.go +++ b/provider/agent.go @@ -49,9 +49,9 @@ func agentResource() *schema.Resource { return diag.FromErr(err) } } - return updateInitScript(resourceData, i) - }, + return updateInitScript(resourceData, i) + }, ReadWithoutTimeout: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { token := agentAuthToken(ctx, "") err := resourceData.Set("token", token) @@ -74,9 +74,8 @@ func agentResource() *schema.Resource { } } - return updateInitScript(resourceData, i) - }, - + return updateInitScript(resourceData, i) + }, DeleteContext: func(ctx context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics { return nil }, @@ -112,20 +111,17 @@ func agentResource() *schema.Resource { Description: "The authentication type the agent will use. Must be one of: `\"token\"`, `\"google-instance-identity\"`, `\"aws-instance-identity\"`, `\"azure-instance-identity\"`.", ValidateFunc: validation.StringInSlice([]string{"token", "google-instance-identity", "aws-instance-identity", "azure-instance-identity"}, false), }, - "dir": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, - Deprecated: "dir has been deprecated and will be removed in a future release.", - Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`." + - "\n\n~> **Warning:** This attribute is deprecated and will be removed in a future release.", - ValidateFunc: helpers.WarnDirNotHome, - }, - + "dir": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + Description: "The starting directory when a user creates a shell session. Defaults to `\"$HOME\"`. " + + "SFTP and scp resolve relative and `~/`-prefixed paths against this directory, " + + "so use absolute paths for file transfers.", + }, "env": { ForceNew: true, Description: "A mapping of environment variables to set inside the workspace.", - Type: schema.TypeMap, Optional: true, }, diff --git a/provider/helpers/validation.go b/provider/helpers/validation.go index ce13257e..8e22ecf5 100644 --- a/provider/helpers/validation.go +++ b/provider/helpers/validation.go @@ -21,19 +21,6 @@ func ValidateURL(value any, label string) ([]string, []error) { return nil, nil } -// WarnDirNotHome returns a warning if dir is set to a value other -// than $HOME. The dir attribute is deprecated and will be removed in -// a future release. -func WarnDirNotHome(val interface{}, _ string) ([]string, []error) { - d, ok := val.(string) - if !ok || d == "" || d == "$HOME" || d == "~" { - return nil, nil - } - return []string{ - `"dir" is deprecated and will be removed in a future release.`, - }, nil -} - // ValidateExternalURL validates that value is a URL the browser's URL can parse. // An external app URL must carry a scheme and hostname func ValidateExternalURL(value string) error { diff --git a/provider/helpers/validation_test.go b/provider/helpers/validation_test.go index 79208fbc..daee783b 100644 --- a/provider/helpers/validation_test.go +++ b/provider/helpers/validation_test.go @@ -150,60 +150,6 @@ func TestValidateURL(t *testing.T) { } } -func TestWarnDirNotHome(t *testing.T) { - tests := []struct { - name string - value interface{} - warnCount int - }{ - // No warnings expected. - { - name: "empty string", - value: "", - warnCount: 0, - }, - { - name: "$HOME", - value: "$HOME", - warnCount: 0, - }, - { - name: "tilde", - value: "~", - warnCount: 0, - }, - { - name: "non-string type", - value: 123, - warnCount: 0, - }, - // Warnings expected. - { - name: "absolute path", - value: "/workspace", - warnCount: 1, - }, - { - name: "relative path", - value: "projects/foo", - warnCount: 1, - }, - { - name: "tilde subdir", - value: "~/projects", - warnCount: 1, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - warnings, errors := WarnDirNotHome(tt.value, "dir") - require.Empty(t, errors, "expected no errors") - require.Len(t, warnings, tt.warnCount) - }) - } -} - func TestValidateExternalURL(t *testing.T) { tests := []struct { name string