From 9fb3fd45036466ab0d7b8d72da843ef58333d36f Mon Sep 17 00:00:00 2001 From: ramya18101 Date: Thu, 30 Oct 2025 10:52:22 +0530 Subject: [PATCH 1/2] enhance quickstart request handling with User-Agent and content type validation --- internal/auth0/quickstart.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/auth0/quickstart.go b/internal/auth0/quickstart.go index ae2b6e31e..b91b685c8 100644 --- a/internal/auth0/quickstart.go +++ b/internal/auth0/quickstart.go @@ -9,7 +9,9 @@ import ( "net/url" "os" "path" + "strings" + "github.com/auth0/auth0-cli/internal/buildinfo" "github.com/auth0/go-auth0/management" "github.com/auth0/auth0-cli/internal/utils" @@ -62,6 +64,9 @@ func (q Quickstart) Download(ctx context.Context, downloadPath string, client *m request.URL.RawQuery = params.Encode() request.Header.Set("Content-Type", "application/json") + userAgent := "Auth0 CLI" // Set User-Agent header using the standard CLI format. + request.Header.Set("User-Agent", fmt.Sprintf("%v/%v", userAgent, strings.TrimPrefix(buildinfo.Version, "v"))) + response, err := http.DefaultClient.Do(request) if err != nil { return err @@ -71,6 +76,12 @@ func (q Quickstart) Download(ctx context.Context, downloadPath string, client *m return fmt.Errorf("expected status %d, got %d", http.StatusOK, response.StatusCode) } + // Check if we're getting a zip file or HTML response + contentType := response.Header.Get("Content-Type") + if contentType != "" && !strings.Contains(contentType, "application/zip") && !strings.Contains(contentType, "application/octet-stream") { + return fmt.Errorf("expected zip file but got content-type: %s. The quickstart endpoint may have returned an error page", contentType) + } + tmpFile, err := os.CreateTemp("", "auth0-quickstart*.zip") if err != nil { return err From 6039d67c0ef13e84b7d8d339f41d9c10f45abcfe Mon Sep 17 00:00:00 2001 From: ramya18101 Date: Mon, 3 Nov 2025 11:30:01 +0530 Subject: [PATCH 2/2] fix lint --- internal/auth0/quickstart.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/auth0/quickstart.go b/internal/auth0/quickstart.go index b91b685c8..60a10fee2 100644 --- a/internal/auth0/quickstart.go +++ b/internal/auth0/quickstart.go @@ -11,9 +11,10 @@ import ( "path" "strings" - "github.com/auth0/auth0-cli/internal/buildinfo" "github.com/auth0/go-auth0/management" + "github.com/auth0/auth0-cli/internal/buildinfo" + "github.com/auth0/auth0-cli/internal/utils" ) @@ -76,7 +77,7 @@ func (q Quickstart) Download(ctx context.Context, downloadPath string, client *m return fmt.Errorf("expected status %d, got %d", http.StatusOK, response.StatusCode) } - // Check if we're getting a zip file or HTML response + // Check if we're getting a zip file or HTML response. contentType := response.Header.Get("Content-Type") if contentType != "" && !strings.Contains(contentType, "application/zip") && !strings.Contains(contentType, "application/octet-stream") { return fmt.Errorf("expected zip file but got content-type: %s. The quickstart endpoint may have returned an error page", contentType)