Skip to content

Commit 3075fda

Browse files
committed
Fix telemetry acceptance tests and pydabs check-formatting
The .well-known/databricks-config request (added by the SDK bump) became the first recorded request in out.requests.txt. Since it lacks a cmd-exec-id in User-Agent, extract_command_exec_id.py failed on its first JSON object. Fix the script to iterate through all objects until finding one with cmd-exec-id. Also add a Repls pattern for compact JSON execution_time_ms (no space after colon, as it appears in protoLogs strings) and regenerate all affected golden files. For pydabs/check-formatting, regenerate with ruff installed so the output reflects actual formatting checks. Co-authored-by: Isaac
1 parent f21dc10 commit 3075fda

File tree

21 files changed

+163
-1354
lines changed

21 files changed

+163
-1354
lines changed

acceptance/bin/extract_command_exec_id.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,31 @@
88
def extract_cmd_exec_id():
99
requests_file = Path("out.requests.txt")
1010

11-
# Read until we find a complete JSON object. This is required because we pretty
12-
# print the JSON object (with new lines) in the out.requests.txt file.
11+
# Read JSON objects one at a time and find the first one with a cmd-exec-id
12+
# in the User-Agent header. Some requests (e.g. .well-known/databricks-config)
13+
# are made before the command execution context is set and lack cmd-exec-id.
1314
with requests_file.open("r") as f:
1415
json_str = ""
1516
while True:
1617
line = f.readline()
1718
if not line:
18-
raise SystemExit("Requests file is empty")
19+
break
1920

2021
json_str += line
2122
try:
22-
# Try to parse the accumulated string as JSON
2323
data = json.loads(json_str)
24-
break
2524
except json.JSONDecodeError:
26-
# If incomplete, continue reading
2725
continue
2826

29-
user_agent = data["headers"]["User-Agent"][0]
30-
31-
if not user_agent:
32-
raise SystemExit("User-Agent header is empty")
27+
# Reset for next JSON object
28+
json_str = ""
3329

34-
match = re.search(r"cmd-exec-id/([^\s]+)", user_agent)
35-
if match:
36-
return match.group(1)
30+
user_agent = data.get("headers", {}).get("User-Agent", [""])[0]
31+
match = re.search(r"cmd-exec-id/([^\s]+)", user_agent)
32+
if match:
33+
return match.group(1)
3734

38-
raise SystemExit(f"No command execution ID found in User-Agent: {user_agent}")
35+
raise SystemExit("No command execution ID found in any request in out.requests.txt")
3936

4037

4138
if __name__ == "__main__":

acceptance/bundle/telemetry/deploy-error/out.requests.txt

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

acceptance/bundle/telemetry/deploy-error/out.telemetry.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"execution_context": {
3-
"cmd_exec_id": "[UUID]",
3+
"cmd_exec_id": "[CMD-EXEC-ID]",
44
"version": "[DEV_VERSION]",
55
"command": "bundle_deploy",
66
"operating_system": "[OS]",

acceptance/bundle/telemetry/deploy-error/output.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ Error: unable to define default workspace root: bundle name not defined
66
Exit code: 1
77

88
>>> cat out.requests.txt
9-
No command execution ID found in User-Agent: cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS]
10-
11-
Exit code: 1

0 commit comments

Comments
 (0)