Skip to content

Commit 7745f1d

Browse files
Release databricks-sdk-py (#1648)
Automated release of `databricks-sdk-py`: regenerated SDK plus the changelog, version bump, and release-ledger update. See CHANGELOG.md for the released version(s). Co-authored-by: databricks-ci-ghec-2[bot] <184307802+databricks-ci-ghec-2[bot]@users.noreply.github.com>
1 parent afc623d commit 7745f1d

55 files changed

Lines changed: 3108 additions & 540 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.codegen.json‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

‎.codegen/_last_sha‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
135055fc276ed13622fe66c430bcff841b35d825
1+
53e4c6273d2874b13429a178dbbc57b5aac59fbb

‎.github/dependabot.yml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@ updates:
1212
interval: monthly
1313
cooldown:
1414
default-days: 7
15-
# tagging.yml is generated and maintained externally.
16-
exclude-paths:
17-
- .github/workflows/tagging.yml

‎.github/workflows/tagging.yml‎

Lines changed: 0 additions & 89 deletions
This file was deleted.

‎CHANGELOG.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Version changelog
22

3+
## Release v0.171.0 (2026-11-25)
4+
5+
### API Changes
6+
* Add `databricks.sdk.service.geniemigrate` package.
7+
* Add [w.genie_migrate](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/geniemigrate/genie_migrate.html) workspace-level service.
8+
* Add `resources` field for `databricks.sdk.service.genieagents.GenieAgentDefinition`.
9+
* Add `text_instruction` field for `databricks.sdk.service.genieagents.GenieAgentInstructions`.
10+
* Add `asset_type_metric_view` and `asset_type_agent_skill` enum values for `databricks.sdk.service.marketplace.AssetType`.
11+
* [Breaking] Remove `data_sources` field for `databricks.sdk.service.genieagents.GenieAgentDefinition`.
12+
* [Breaking] Remove `sql_functions` and `text_instructions` fields for `databricks.sdk.service.genieagents.GenieAgentInstructions`.
13+
* [Breaking] Remove `notifications` field for `databricks.sdk.service.ml.MaterializationSet`.
14+
315
## Release v0.170.0 (2026-11-23)
416

517
### API Changes

‎databricks/sdk/__init__.py‎

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎databricks/sdk/common/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# A regular package, so that the extended databricks.sdk.__path__ doesn't merge in
2+
# another installed SDK copy's common/ (see databricks/sdk/__init__.py).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# ruff: noqa: E402
2+
3+
# Other libraries can install packages under `databricks.sdk.environments`, possibly
4+
# into another sys.path entry, so search them all.
5+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
6+
17
from dataclasses import dataclass
28
from enum import Enum
39
from typing import Optional

‎databricks/sdk/mixins/sandbox.py‎

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ def _raise_if_failed(self) -> None:
526526
_FRAMING_HEADERS = frozenset({"content-length", "transfer-encoding"})
527527
# Workspace gateways read identity and routing from these, so only the SDK's credentials may set them.
528528
_GATEWAY_HEADER_PREFIXES = ("x-databricks-", "s2s-")
529+
_LOOPBACK_HOSTS = ("127.0.0.1", "localhost")
529530

530531

531532
class Forward:
@@ -679,6 +680,9 @@ def _relay(self, client: socket.socket) -> None:
679680
if request is None:
680681
client.sendall(_error_response(400, "Bad Request", "malformed request, or an unsupported path"))
681682
return
683+
if _is_cross_site(request, self.server.server_address[1]):
684+
client.sendall(_error_response(403, "Forbidden", "requests must come from the forward's own URL"))
685+
return
682686
target = self.server.target
683687
try:
684688
auth_headers = target.authenticate()
@@ -795,6 +799,55 @@ def _parse_request(head: bytes) -> Optional[_Request]:
795799
return _Request(method, request_target, version, headers, connection_tokens, upgrade, body_length)
796800

797801

802+
def _is_cross_site(request: _Request, local_port: int) -> bool:
803+
"""Whether a browser sent the request for a page that is neither the forward nor a local app.
804+
805+
The relay attaches the SDK's credentials to every request, so a page on another site must
806+
not be able to make the user's browser send one. A ``Host`` other than the loopback address
807+
the relay listens on means the browser reached it through another name. A loopback ``Origin``
808+
passes whatever ``Sec-Fetch-Site`` says. Top-level GET navigations from other sites stay
809+
allowed, so links and sign-in redirects to the app work.
810+
Clients other than browsers send no ``Origin`` or ``Sec-Fetch-*`` headers and pass.
811+
"""
812+
values: Dict[str, List[str]] = {}
813+
for name, value in request.headers:
814+
values.setdefault(name.lower(), []).append(value)
815+
if any(len(values.get(name, [])) > 1 for name in ("host", "sec-fetch-site", "sec-fetch-mode", "sec-fetch-dest")):
816+
return True
817+
if not _is_loopback_authority(values.get("host", [""])[0], local_port):
818+
return True
819+
origins = values.get("origin", [])
820+
if not all(_is_loopback_origin(origin) for origin in origins):
821+
return True
822+
# A page on the other loopback name, such as localhost:5173 calling 127.0.0.1, is cross-site
823+
# to the browser; its Origin, which pages can't set, still shows the page is local.
824+
if origins or values.get("sec-fetch-site", ["none"])[0].lower() in ("same-origin", "same-site", "none"):
825+
return False
826+
navigation = (
827+
request.method in ("GET", "HEAD")
828+
and values.get("sec-fetch-mode", [""])[0].lower() == "navigate"
829+
and values.get("sec-fetch-dest", [""])[0].lower() == "document"
830+
)
831+
return not navigation
832+
833+
834+
def _is_loopback_authority(authority: str, port: int) -> bool:
835+
allowed = {f"{host}:{port}" for host in _LOOPBACK_HOSTS}
836+
if port == 80:
837+
allowed.update(_LOOPBACK_HOSTS)
838+
return authority.lower() in allowed
839+
840+
841+
def _is_loopback_origin(origin: str) -> bool:
842+
"""Whether ``origin`` is an ``http`` origin on a loopback name, such as a local frontend
843+
calling the forwarded app. Any port is allowed."""
844+
try:
845+
parsed = urlsplit(origin)
846+
except ValueError:
847+
return False
848+
return parsed.scheme == "http" and parsed.hostname in _LOOPBACK_HOSTS and parsed.path == ""
849+
850+
798851
def _rewrite_head(request: _Request, target: _Target, auth_headers: Dict[str, str]) -> bytes:
799852
"""Points the request at the sandbox port and replaces the caller's credentials with ``auth_headers``.
800853
@@ -1085,14 +1138,18 @@ def forward(self, name: str, remote_port: int, *, local_port: int = 0) -> Forwar
10851138
``{sandbox_id}`` is also accepted. :attr:`Forward.url` is the local URL
10861139
to send requests to.
10871140
1088-
The app must listen on ``0.0.0.0`` inside the sandbox. Ports 10000-65535
1089-
are forwardable except 10101, 18767, and 19090. Clients speak HTTP/1.1 to
1141+
The app must listen on ``0.0.0.0`` inside the sandbox. The sandbox refuses
1142+
a few reserved platform ports; a request to a refused port gets a 403
1143+
response with a message saying why. Clients speak HTTP/1.1 to
10901144
the local port, including WebSocket upgrades; each local connection carries
10911145
one request. Requests whose path has a ``.`` or ``..`` segment, a ``;``, a
10921146
backslash, a control character, or an encoded ``/``, ``\\``, ``%``, ``?``,
10931147
or ``#`` get a local 400 response and are never sent, as do malformed
1094-
heads. The caller's ``Authorization``, ``X-Databricks-*``, and ``S2S-*``
1095-
headers are not forwarded, and the SDK's credentials are added.
1148+
heads. Requests must name ``127.0.0.1:<local_port>`` or
1149+
``localhost:<local_port>`` as ``Host``; requests that a page on another site
1150+
makes a browser send get a 403, except top-level page loads. The caller's
1151+
``Authorization``, ``X-Databricks-*``, and ``S2S-*`` headers are not
1152+
forwarded, and the SDK's credentials are added.
10961153
"""
10971154
cfg = self._api._cfg
10981155
if not cfg.host:
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# ruff: noqa: E402
2+
3+
# Other libraries can install packages under `databricks.sdk.oauth`, possibly
4+
# into another sys.path entry, so search them all.
5+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
6+
17
import base64
28
import functools
39
import hashlib
@@ -19,8 +25,8 @@
1925
import requests
2026
import requests.auth
2127

22-
from ._base_client import _BaseClient, _fix_host_if_needed
23-
from .environments import Cloud
28+
from .._base_client import _BaseClient, _fix_host_if_needed
29+
from ..environments import Cloud
2430

2531
# Error code for PKCE flow in Azure Active Directory, that gets additional retry.
2632
# See https://stackoverflow.com/a/75466778/277035 for more info
@@ -787,8 +793,8 @@ def from_host(
787793
scopes: List[str] = None,
788794
client_secret: str = None,
789795
) -> "OAuthClient":
790-
from .core import Config
791-
from .credentials_provider import credentials_strategy
796+
from ..core import Config
797+
from ..credentials_provider import credentials_strategy
792798

793799
@credentials_strategy("noop", [])
794800
def noop_credentials(_: any):

0 commit comments

Comments
 (0)