Skip to content

Commit 5e5598c

Browse files
authored
Merge branch 'postmanlabs/observability-cli:main' into main (#11)
2 parents b9e748d + 7352d81 commit 5e5598c

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

cmd/internal/cmderr/checks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ func RequirePostmanAPICredentials(explanation string) (string, error) {
1515
if key == "" {
1616
printer.Errorf("No Postman API key configured. %s\n", explanation)
1717
if env.InDocker() {
18-
printer.Infof("Please set the POSTMAN_API_KEY environment variables on the Docker command line.\n")
18+
printer.Infof("Please set the POSTMAN_API_KEY environment variable on the Docker command line.\n")
1919
} else {
20-
printer.Infof("Use the POSTMAN_API_KEY environment variables, or run 'postman-insights-agent login'.\n")
20+
printer.Infof("Please set the POSTMAN_API_KEY environment variable, either in your shell session or prepend it to postman-insights-agent command.\n")
2121
}
22-
23-
return "", AkitaErr{Err: errors.New("could not find an Postman API key to use")}
22+
//lint:ignore ST1005 This is a user-facing error message
23+
return "", AkitaErr{Err: errors.New("Could not find a Postman API key to use")}
2424
}
2525

2626
return key, nil

cmd/internal/ecs/ecs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func checkAPIKeyAndProjectID() error {
150150
return err
151151
}
152152

153-
// Check that a collection or project is provided.
153+
// Check that project ID is provided.
154154
if projectId == "" {
155155
return errors.New("--project must be specified")
156156
}

rest/http.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/pkg/errors"
1515

1616
"github.com/akitasoftware/akita-cli/cfg"
17+
"github.com/akitasoftware/akita-cli/consts"
1718
"github.com/akitasoftware/akita-cli/printer"
1819
"github.com/akitasoftware/akita-cli/version"
1920
"github.com/akitasoftware/akita-libs/spec_util"
@@ -22,6 +23,9 @@ import (
2223
const (
2324
// TODO: Make this tunable.
2425
defaultClientTimeout = 5 * time.Second
26+
unexpectedErrMsg = "Unexpected error occured while making request, status code: %d. " +
27+
"If the issue persists, run the agent with debug logs enabled (--debug), and " +
28+
"contact Postman support (" + consts.SupportEmail + ") with the error logs."
2529
)
2630

2731
var (
@@ -40,7 +44,8 @@ func (he HTTPError) Error() string {
4044
if he.StatusCode == 401 {
4145
return `Invalid credentials. Ensure the POSTMAN_API_KEY environment variable has a valid API key for Postman.`
4246
}
43-
return fmt.Sprintf("received status code %d, body: %s", he.StatusCode, string(he.Body))
47+
printer.Debugln("Unexpected error, received status code:", he.StatusCode, "body:", string(he.Body))
48+
return fmt.Sprintf(unexpectedErrMsg, he.StatusCode)
4449
}
4550

4651
// Implements retryablehttp LeveledLogger interface using printer.

util/util.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func GetServiceIDByName(c rest.FrontClient, name string) (akid.ServiceID, error)
9898
}
9999

100100
func GetServiceNameByServiceID(c rest.FrontClient, serviceID akid.ServiceID) (string, error) {
101-
unexpectedErrMsg := "Something went wrong while starting the Agent. " +
101+
unexpectedErrMsg := "Something went wrong while starting the agent. " +
102102
"Please contact Postman support (" + consts.SupportEmail + ") with the error details"
103103
failedToGetProjectErrMsg := "Failed to get project for given projectID: %s\n"
104104

@@ -173,8 +173,7 @@ func GetServiceIDByPostmanCollectionID(c rest.FrontClient, ctx context.Context,
173173
func GetOrCreateServiceIDByPostmanCollectionID(c rest.FrontClient, collectionID string) (akid.ServiceID, error) {
174174
// Normalize the collectionID.
175175
collectionID = strings.ToLower(collectionID)
176-
unexpectedErrMsg := "Something went wrong while starting the Agent. " +
177-
"Please contact Postman support (" + consts.SupportEmail + ") with the error details"
176+
unexpectedErrMsg := "Something went wrong while starting the agent."
178177
failedToCreateProjectErrMsg := "Failed to create project for given collectionID: %s\n"
179178

180179
if id, found := postmanCollectionIDCache.Get(collectionID); found {

0 commit comments

Comments
 (0)