diff --git a/internal/cli/auth.go b/internal/cli/auth.go index 68b7a9a..8fef1ea 100644 --- a/internal/cli/auth.go +++ b/internal/cli/auth.go @@ -6,6 +6,7 @@ package cli import ( "bytes" "encoding/json" + "errors" "fmt" "net/url" "os" @@ -65,7 +66,7 @@ func newAuthLoginCmd(flags *rootFlags) *cobra.Command { Short: "Automated login using a browser (requires Python + Playwright)", RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("Attempting automated session refresh...") - + // Check if script exists scriptPath := "scripts/refresh_auth.js" if _, err := os.Stat(scriptPath); os.IsNotExist(err) { @@ -91,7 +92,7 @@ func newAuthLoginCmd(flags *rootFlags) *cobra.Command { } cookieString := strings.TrimSpace(matches[1]) - + // Save the token cfg, err := config.Load(flags.configPath) if err != nil { @@ -317,7 +318,7 @@ How to get a HAR file: var bestCookie string bestHeaders := make(map[string]string) - + // Pass 1: Aggregate all bot-detection headers found anywhere in the HAR for _, entry := range har.Log.Entries { for _, header := range entry.Request.Headers { @@ -334,7 +335,7 @@ How to get a HAR file: if err != nil { continue } - + isSkool := strings.Contains(u.Host, "skool.com") if isSkool { for _, header := range entry.Request.Headers { @@ -355,7 +356,6 @@ How to get a HAR file: } found: - if bestCookie == "" { msg := "no session cookies found in HAR file.\n" if len(har.Log.Entries) == 0 { @@ -364,7 +364,8 @@ How to get a HAR file: msg += fmt.Sprintf("Found %d requests, but none contained Skool authentication material.\n", len(har.Log.Entries)) msg += "Ensure you REFRESH the page while the Network tab is open before exporting." } - return fmt.Errorf(msg) + // PATCH: Return dynamic prose as an error value without treating it as a format string. + return errors.New(msg) } cfg, err := config.Load(flags.configPath) diff --git a/internal/cli/install.go b/internal/cli/install.go index 679feba..94e9938 100644 --- a/internal/cli/install.go +++ b/internal/cli/install.go @@ -34,14 +34,15 @@ This avoids the need for sudo/root permissions.`, } target := filepath.Join(binDir, "skool-pp-cli") - + // Copy binary input, err := os.ReadFile(exe) if err != nil { return fmt.Errorf("reading current binary: %w", err) } if err := os.WriteFile(target, input, 0755); err != nil { - return fmt.Errorf("writing binary to %s: %w", target, binDir) + // PATCH: Wrap the write error rather than passing the destination directory to %w. + return fmt.Errorf("writing binary to %s: %w", target, err) } fmt.Printf("✓ Binary installed to %s\n", target) @@ -51,7 +52,7 @@ This avoids the need for sudo/root permissions.`, if !strings.Contains(pathEnv, binDir) { fmt.Println("\n⚠ This directory is not in your PATH.") fmt.Println("To add it, run the following command or add it to your shell profile (.zshrc or .bash_profile):") - + shell := filepath.Base(os.Getenv("SHELL")) if shell == "" { shell = "your shell" @@ -59,7 +60,7 @@ This avoids the need for sudo/root permissions.`, exportCmd := fmt.Sprintf("export PATH=\"%s:$PATH\"", binDir) fmt.Printf("\n %s\n\n", exportCmd) - + if runtime.GOOS == "darwin" || runtime.GOOS == "linux" { profile := ".zshrc" if strings.Contains(shell, "bash") {