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
{{ message }}
Repository navigation
Commit 95ca5f1
Browse filesBrowse the repository at this point in the historyBrowse files
- Share sandbox resolution with `sandbox ssh` (resolveSandbox), and reject
IDs that are not a single path segment. A 400 from the lookup now fails
instead of warning.
- Let a loopback Origin take precedence over Sec-Fetch-Site, so a frontend
on http://localhost:N can call the printed http://127.0.0.1:N URL.
- Send the package's X-Databricks-Org-Id routing header, as the sandbox API
does.
- Add an acceptance test that forwards a request end to end.
Co-authored-by: Isaac <no-reply@databricks.com>
return"", "", errors.New("no default sandbox configured — run `databricks sandbox create` to provision one, or `databricks sandbox default <id>` to point at an existing sandbox")
// The ID is a segment of every forwarded path, so "." or ".." would move
186
-
// requests off the port-forward route.
187
-
ifsandboxID=="."||sandboxID==".." {
188
-
return"", "", fmt.Errorf("invalid sandbox ID %q", sandboxID)
189
-
}
190
-
191
-
entry, err:=api.get(ctx, sandboxID)
192
-
iferr!=nil {
193
-
switch {
194
-
case!errors.Is(err, apierr.ErrNotFound):
195
-
warn(ctx, fmt.Sprintf("Could not validate sandbox %s: %v", sandboxID, err))
196
-
returnsandboxID, "", nil
197
-
caselen(args) ==0:
198
-
_=clearDefault(ctx, profile)
199
-
return"", "", fmt.Errorf("saved default %q no longer exists (cleared) — run `databricks sandbox create` to provision a new one, or `databricks sandbox default <id>` to point at an existing sandbox", sandboxID)
200
-
default:
201
-
return"", "", fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID)
202
-
}
203
-
}
204
-
returnsandboxID, entry.Status, nil
205
-
}
206
-
207
169
// newPortForwardTransport returns the workspace config's transport, or the
208
170
// default one with the config's TLS verification setting.
return"", nil, errors.New("no default sandbox configured — run `databricks sandbox create` to provision one, or `databricks sandbox default <id>` to point at an existing sandbox")
77
+
}
78
+
} else {
79
+
resolved, err:=resolveLocalID(ctx, profile, arg)
80
+
iferr!=nil {
81
+
return"", nil, err
82
+
}
83
+
sandboxID=resolved
84
+
}
85
+
iferr:=validateSandboxID(sandboxID); err!=nil {
86
+
return"", nil, err
87
+
}
88
+
89
+
sb, err:=api.get(ctx, sandboxID)
90
+
switch {
91
+
caseerr==nil:
92
+
returnsandboxID, sb, nil
93
+
caseerrors.Is(err, apierr.ErrNotFound) &&arg=="":
94
+
// A stale default is almost always user-correctable (deleted from
95
+
// another machine, reaped by an admin); fail fast with an actionable
96
+
// message.
97
+
_=clearDefault(ctx, profile)
98
+
return"", nil, fmt.Errorf("saved default %q no longer exists (cleared) — run `databricks sandbox create` to provision a new one, or `databricks sandbox default <id>` to point at an existing sandbox", sandboxID)
99
+
caseerrors.Is(err, apierr.ErrNotFound):
100
+
return"", nil, fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID)
101
+
caseerrors.Is(err, apierr.ErrBadRequest):
102
+
return"", nil, fmt.Errorf("failed to look up sandbox %s: %w", sandboxID, err)
103
+
default:
104
+
warn(ctx, fmt.Sprintf("Could not validate sandbox %s: %v", sandboxID, err))
105
+
returnsandboxID, nil, nil
106
+
}
107
+
}
108
+
109
+
// validateSandboxID rejects IDs that are not a single path segment. Commands
110
+
// put the ID in workspace URL paths, and the workspace decodes an escaped "/",
111
+
// so a separator or dot segment would move a request onto another API with the
0 commit comments