Skip to content

Commit

Permalink
[resultdb] Add more context to error messages
Browse files Browse the repository at this point in the history
... on the off chance that somebody has the `LUCI_CONTEXT` env var set
locally with some invalid value.

Change-Id: I38c247b42706529e01de649ed3a0f47a62e3cd6e
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/927714
Commit-Queue: Auto-Submit <[email protected]>
Reviewed-by: Anthony Fandrianto <[email protected]>
Fuchsia-Auto-Submit: Oliver Newman <[email protected]>
  • Loading branch information
orn688 authored and CQ Bot committed Oct 5, 2023
1 parent 5d6681e commit 2ca3a4f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/reporting/resultdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ func (r *resultSinkContext) sendData(ctx context.Context, client *http.Client, e

// resultSinkCtx returns the rdb stream port if available.
func resultSinkCtx() (*resultSinkContext, error) {
b, err := os.ReadFile(os.Getenv("LUCI_CONTEXT"))
path := os.Getenv("LUCI_CONTEXT")
b, err := os.ReadFile(path)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to load LUCI_CONTEXT=%q: %w", path, err)
}
var ctx luciContext
if err = json.Unmarshal(b, &ctx); err != nil {
return nil, err
return nil, fmt.Errorf("failed to load LUCI_CONTEXT=%q: %w", path, err)
}
// We are clearly running inside a LUCI_CONTEXT luciexe environment but rdb
// stream was not started. Hard fail since it means we need to fix the recipe.
Expand Down

0 comments on commit 2ca3a4f

Please sign in to comment.