-
Notifications
You must be signed in to change notification settings - Fork 150
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,7 @@ func ProcessBundle(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle, err | |
| return b, err | ||
| } | ||
|
|
||
| func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle, *statemgmt.StateDesc, error) { | ||
| func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (b *bundle.Bundle, stateDesc *statemgmt.StateDesc, retErr error) { | ||
| var err error | ||
| ctx := cmd.Context() | ||
| if opts.SkipInitContext { | ||
|
|
@@ -93,7 +93,24 @@ func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle, | |
| } | ||
|
|
||
| // Load bundle config and apply target | ||
| b := root.MustConfigureBundle(cmd) | ||
| b = root.MustConfigureBundle(cmd) | ||
|
|
||
| // Log deploy telemetry on all exit paths. This is a defer to ensure | ||
| // telemetry is logged even when the deploy command fails, for both | ||
| // diagnostic errors and regular Go errors. | ||
| if opts.Deploy { | ||
| defer func() { | ||
| if b == nil { | ||
| return | ||
| } | ||
| errMsg := logdiag.GetFirstErrorSummary(ctx) | ||
| if errMsg == "" && retErr != nil && !errors.Is(retErr, root.ErrAlreadyPrinted) { | ||
| errMsg = retErr.Error() | ||
|
Comment on lines
+103
to
+108
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SUGGESTION] No new unit tests for the defer + error capture logic. The core behavior change (telemetry always fires, error message captured from logdiag or retErr) should have test coverage. Consider testing:
|
||
| } | ||
| phases.LogDeployTelemetry(ctx, b, errMsg) | ||
| }() | ||
|
Comment on lines
+98
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMPORTANT] This defer runs whenever Fix: guard with
Comment on lines
+98
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMPORTANT] This defer will now log a full Fix: remove the root-level failure fallback, or gate it on "no deploy event was already logged". |
||
| } | ||
|
|
||
| if logdiag.HasError(ctx) { | ||
| return b, nil, root.ErrAlreadyPrinted | ||
| } | ||
|
|
@@ -147,8 +164,6 @@ func ProcessBundleRet(cmd *cobra.Command, opts ProcessOptions) (*bundle.Bundle, | |
| } | ||
| } | ||
|
|
||
| var stateDesc *statemgmt.StateDesc | ||
|
|
||
| shouldReadState := opts.ReadState || opts.AlwaysPull || opts.InitIDs || opts.ErrorOnEmptyState || opts.PreDeployChecks || opts.Deploy || opts.ReadPlanPath != "" | ||
|
|
||
| if shouldReadState { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMPORTANT]
ErrorMessageis sent verbatim fromlogdiag.GetFirstErrorSummary()/retErr.Error(). Many deploy errors interpolate local filesystem paths or user-controlled config values (e.g., fromstatemgmt/state_pull.go,config/mutator/translate_paths.go). This starts shipping raw PII/workspace details to telemetry with no sanitization or size bound.Fix: emit a sanitized error code/category, or at least scrub paths and cap length (e.g., 500 chars).