Skip to content

Commit 60fba4e

Browse files
bundle: drop the state-path-outside-root warning, keep it as telemetry only
Storing workspace.state_path outside workspace.root_path is a valid configuration, not a misconfiguration, so it should not produce a warning. ValidateWorkspacePermissions now warns only when a path's effective access exceeds the declared permissions (cases 1 and 2). The StatePathOutsideRootPath predicate and its telemetry field remain as an informational signal. Co-authored-by: Shreyas Goenka <shreyas.goenka@databricks.com>
1 parent c4bc392 commit 60fba4e

2 files changed

Lines changed: 8 additions & 50 deletions

File tree

bundle/permissions/validate.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import (
1313
type validateWorkspacePermissions struct{}
1414

1515
// ValidateWorkspacePermissions statically validates workspace path configurations
16-
// for potential permission misconfigurations. It emits a warning for each of the
17-
// following, all of which are also recorded as telemetry via the predicates below:
16+
// and warns when a workspace path grants broader access than the top-level
17+
// permissions section declares:
1818
//
1919
// 1. workspace.root_path grants broader access than the permissions section
2020
// declares (RootPathScopeExceedsPermissions).
2121
// 2. workspace.state_path grants broader access than the permissions section
2222
// declares (StatePathScopeExceedsPermissions).
23-
// 3. workspace.state_path is stored outside workspace.root_path, so its
24-
// permissions are managed independently (StatePathOutsideRootPath).
23+
//
24+
// Note: StatePathOutsideRootPath is intentionally not warned about — storing the
25+
// state outside the bundle root is a valid configuration, not a misconfiguration.
26+
// It is still recorded as telemetry.
2527
func ValidateWorkspacePermissions() bundle.Mutator {
2628
return &validateWorkspacePermissions{}
2729
}
@@ -56,16 +58,6 @@ func (*validateWorkspacePermissions) Apply(ctx context.Context, b *bundle.Bundle
5658
})
5759
}
5860

59-
// Case 3: state_path is stored outside root_path.
60-
// Skip when state_path is shared, since case 2 is the more specific warning.
61-
if StatePathOutsideRootPath(b) && !StatePathIsShared(b) {
62-
diags = diags.Append(diag.Diagnostic{
63-
Severity: diag.Warning,
64-
Summary: fmt.Sprintf("workspace.state_path %q is not nested under workspace.root_path %q", statePath, rootPath),
65-
Detail: "The deployment state is stored in a workspace folder separate from the bundle root. Bundle permissions will be applied to this path independently during deployment. Ensure the path is accessible and the configured permissions are appropriate.",
66-
})
67-
}
68-
6961
return diags
7062
}
7163

bundle/permissions/validate_test.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ func TestValidateWorkspacePermissions_BothShared_OnlyOneWarning(t *testing.T) {
109109
assert.Contains(t, diags[0].Summary, "root path")
110110
}
111111

112-
// --- Case 3: state_path outside root_path ---
112+
// state_path outside root_path is informational only — it must not warn.
113113

114-
func TestValidateWorkspacePermissions_StateOutsideRoot_Warn(t *testing.T) {
114+
func TestValidateWorkspacePermissions_StateOutsideRoot_NoWarn(t *testing.T) {
115115
b := &bundle.Bundle{
116116
Config: config.Root{
117117
Workspace: config.Workspace{
@@ -121,43 +121,9 @@ func TestValidateWorkspacePermissions_StateOutsideRoot_Warn(t *testing.T) {
121121
},
122122
}
123123
diags := applyValidate(t, b)
124-
require.Len(t, diags, 1)
125-
assert.Equal(t, diag.Warning, diags[0].Severity)
126-
assert.Contains(t, diags[0].Summary, "workspace.state_path")
127-
assert.Contains(t, diags[0].Summary, "workspace.root_path")
128-
}
129-
130-
func TestValidateWorkspacePermissions_StateInsideRoot_NoWarn(t *testing.T) {
131-
b := &bundle.Bundle{
132-
Config: config.Root{
133-
Workspace: config.Workspace{
134-
RootPath: "/Workspace/Users/user@example.test/bundle",
135-
StatePath: "/Workspace/Users/user@example.test/bundle/state",
136-
},
137-
},
138-
}
139-
diags := applyValidate(t, b)
140124
require.Empty(t, diags)
141125
}
142126

143-
func TestValidateWorkspacePermissions_StateSharedAndOutsideRoot_OnlyCaseTwo(t *testing.T) {
144-
// state_path is in Shared and outside root — only case 2 fires, not case 3.
145-
b := &bundle.Bundle{
146-
Config: config.Root{
147-
Workspace: config.Workspace{
148-
RootPath: "/Workspace/Users/user@example.test/bundle",
149-
StatePath: "/Workspace/Shared/state",
150-
},
151-
Permissions: []resources.Permission{
152-
{Level: CAN_MANAGE, UserName: "user@example.test"},
153-
},
154-
},
155-
}
156-
diags := applyValidate(t, b)
157-
require.Len(t, diags, 1)
158-
assert.Contains(t, diags[0].Summary, "state path")
159-
}
160-
161127
// --- Helper function tests ---
162128

163129
func TestRootPathScopeExceedsPermissions(t *testing.T) {

0 commit comments

Comments
 (0)