-
Notifications
You must be signed in to change notification settings - Fork 152
Add error_message field to bundle deploy telemetry #4793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shreyas-goenka
wants to merge
16
commits into
main
Choose a base branch
from
bundle-deploy-error-message
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1a8ff40
Add error_message field to bundle deploy telemetry
shreyas-goenka 3bc2436
Merge remote-tracking branch 'origin' into bundle-deploy-error-message
shreyas-goenka 5b39bf3
Fix CI failures in deploy telemetry
shreyas-goenka c70dbb1
Cap error message length in deploy telemetry to 500 chars
shreyas-goenka a2fb5dd
Add acceptance test for deploy telemetry error message
shreyas-goenka ca229c4
Scrub sensitive paths and emails from deploy telemetry error messages
shreyas-goenka c5b0903
Simplify telemetry scrubber: remove home-specific code, add workspace…
shreyas-goenka 8cc26b3
Fix Windows drive letter case sensitivity and add Windows bundle root…
shreyas-goenka 34b5228
Remove replacePath; let regex patterns handle all path scrubbing
shreyas-goenka 0242d30
Move tilde home path (~/) to absolute path regex
shreyas-goenka 947e545
Retain known file extensions in redacted paths
shreyas-goenka e4197a8
Add more known file extensions to telemetry scrubber
shreyas-goenka 8d680a8
Add web/app and doc file extensions to telemetry scrubber
shreyas-goenka 968e9fb
Expand known extensions to cover all plausible error message paths
shreyas-goenka 4a0b8d9
Document boundary character choice in path regexes
shreyas-goenka 4919773
Update comment wording for known extensions
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/telemetry/deploy-error-message/databricks.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| variables: | ||
| myvar: | ||
| description: a required variable |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/telemetry/deploy-error-message/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Error: no value assigned to required variable myvar. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_myvar environment variable, or .databricks/bundle/<target>/variable-overrides.json | ||
|
|
||
|
|
||
| Exit code: 1 | ||
|
|
||
| >>> cat out.requests.txt | ||
| no value assigned to required variable myvar. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_myvar environment variable, or [REDACTED_REL_PATH](json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| errcode trace $CLI bundle deploy | ||
|
|
||
| trace cat out.requests.txt | jq -r 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_deploy_event.error_message' | ||
|
|
||
| rm out.requests.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| package phases | ||
|
|
||
| import ( | ||
| "path" | ||
| "regexp" | ||
| "strings" | ||
| ) | ||
|
|
||
| // Scrub sensitive information from error messages before sending to telemetry. | ||
| // Inspired by VS Code's telemetry path scrubbing and Sentry's @userpath pattern. | ||
| // | ||
| // Path regexes use [\s:,"'] as boundary characters to delimit where a path | ||
| // ends. While these characters are technically valid in file paths, in error | ||
| // messages they act as delimiters (e.g. "error: /path/to/file: not found", | ||
| // or "failed to read '/some/path', skipping"). This is a practical tradeoff: | ||
| // paths containing colons, commas, or quotes are extremely rare, and without | ||
| // these boundaries the regexes would over-match into surrounding message text. | ||
| // | ||
| // References: | ||
| // - VS Code: https://github.com/microsoft/vscode/blob/main/src/vs/platform/telemetry/common/telemetryUtils.ts | ||
| // - Sentry: https://github.com/getsentry/relay (PII rule: @userpath) | ||
| var ( | ||
| // Matches Windows absolute paths with at least two components | ||
| // (e.g., C:\foo\bar, D:/projects/myapp). | ||
| windowsAbsPathRegexp = regexp.MustCompile(`[A-Za-z]:[/\\][^\s:,"'/\\]+[/\\][^\s:,"']+`) | ||
|
|
||
| // Matches Databricks workspace paths (/Workspace/...). | ||
| workspacePathRegexp = regexp.MustCompile(`(^|[\s:,"'])(/Workspace/[^\s:,"']+)`) | ||
|
|
||
| // Matches absolute Unix paths with at least two components | ||
| // (e.g., /home/user/..., /tmp/foo, ~/.config/databricks). | ||
| absPathRegexp = regexp.MustCompile(`(^|[\s:,"'])(~?/[^\s:,"'/]+/[^\s:,"']+)`) | ||
|
|
||
| // Matches relative paths: | ||
| // - Explicit: ./foo, ../foo | ||
| // - Dot-prefixed directories: .databricks/bundle/..., .cache/foo | ||
| explicitRelPathRegexp = regexp.MustCompile(`(^|[\s:,"'])((?:\.\.?|\.[a-zA-Z][^\s:,"'/]*)/[^\s:,"']+)`) | ||
|
|
||
| // Matches implicit relative paths: at least two path components where | ||
| // the last component has a file extension (e.g., "resources/job.yml", | ||
| // "bundle/dev/state.json"). | ||
| implicitRelPathRegexp = regexp.MustCompile(`(^|[\s:,"'])([a-zA-Z0-9_][^\s:,"']*/[^\s:,"']*\.[a-zA-Z][^\s:,"']*)`) | ||
|
|
||
| // Matches email addresses. Workspace paths in Databricks often contain | ||
| // emails (e.g., /Workspace/Users/user@example.com/.bundle/dev). | ||
| emailRegexp = regexp.MustCompile(`[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}`) | ||
| ) | ||
|
|
||
| // Known file extensions that are safe to retain in redacted paths. | ||
| // These help understand usage patterns without capturing sensitive information. | ||
| var knownExtensions = map[string]bool{ | ||
| // Configuration and data formats | ||
| ".yml": true, | ||
| ".yaml": true, | ||
| ".json": true, | ||
| ".toml": true, | ||
| ".cfg": true, | ||
| ".ini": true, | ||
| ".env": true, | ||
| ".xml": true, | ||
| ".properties": true, | ||
| ".conf": true, | ||
|
|
||
| // Notebook and script languages | ||
| ".py": true, | ||
| ".r": true, | ||
| ".scala": true, | ||
| ".sql": true, | ||
| ".ipynb": true, | ||
| ".sh": true, | ||
|
|
||
| // Web / Apps | ||
| ".js": true, | ||
| ".ts": true, | ||
| ".jsx": true, | ||
| ".tsx": true, | ||
| ".html": true, | ||
| ".css": true, | ||
|
|
||
| // Terraform | ||
| ".tf": true, | ||
| ".hcl": true, | ||
| ".tfstate": true, | ||
| ".tfvars": true, | ||
|
|
||
| // Build artifacts and archives | ||
| ".whl": true, | ||
| ".jar": true, | ||
| ".egg": true, | ||
| ".zip": true, | ||
| ".tar": true, | ||
| ".gz": true, | ||
| ".tgz": true, | ||
| ".dbc": true, | ||
|
|
||
| // Data formats | ||
| ".txt": true, | ||
| ".csv": true, | ||
| ".md": true, | ||
| ".parquet": true, | ||
| ".avro": true, | ||
|
|
||
| // Logs and locks | ||
| ".log": true, | ||
| ".lock": true, | ||
|
|
||
| // Certificates and keys | ||
| ".pem": true, | ||
| ".crt": true, | ||
| } | ||
|
|
||
| // scrubForTelemetry is a best-effort scrubber that removes sensitive path and | ||
| // PII information from error messages before they are sent to telemetry. | ||
| // The error message is treated as PII by the logging infrastructure but we | ||
| // scrub to avoid collecting more information than necessary. | ||
| func scrubForTelemetry(msg string) string { | ||
| // Redact absolute paths. | ||
| msg = replacePathRegexp(msg, windowsAbsPathRegexp, "[REDACTED_PATH]", false) | ||
| msg = replacePathRegexp(msg, workspacePathRegexp, "[REDACTED_WORKSPACE_PATH]", true) | ||
| msg = replacePathRegexp(msg, absPathRegexp, "[REDACTED_PATH]", true) | ||
|
|
||
| // Redact relative paths. | ||
| msg = replacePathRegexp(msg, explicitRelPathRegexp, "[REDACTED_REL_PATH]", true) | ||
| msg = replacePathRegexp(msg, implicitRelPathRegexp, "[REDACTED_REL_PATH]", true) | ||
|
|
||
| // Redact email addresses. | ||
| msg = emailRegexp.ReplaceAllString(msg, "[REDACTED_EMAIL]") | ||
|
|
||
| return msg | ||
| } | ||
|
|
||
| // replacePathRegexp replaces path matches with the given label, retaining | ||
| // known file extensions. When hasDelimiterGroup is true, the first character | ||
| // of the match is preserved as a delimiter prefix. | ||
| func replacePathRegexp(msg string, re *regexp.Regexp, label string, hasDelimiterGroup bool) string { | ||
| return re.ReplaceAllStringFunc(msg, func(match string) string { | ||
| prefix := "" | ||
| p := match | ||
| if hasDelimiterGroup && len(match) > 0 { | ||
| first := match[0] | ||
| if strings.ContainsRune(" \t\n:,\"'", rune(first)) { | ||
| prefix = match[:1] | ||
| p = match[1:] | ||
| } | ||
| } | ||
|
|
||
| ext := path.Ext(p) | ||
| if knownExtensions[ext] { | ||
| return prefix + label + "(" + ext[1:] + ")" | ||
| } | ||
| return prefix + label | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.