Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,22 @@
tui.ShowWarning("Please re-run the login command to continue")
os.Exit(1)
}


authURL := fmt.Sprintf("%s/auth/cli", appUrl)

body := tui.Paragraph(
"Copy the following code:",
tui.Bold(otp),
"Then open the url in your browser and paste the code:",
tui.Link("%s/auth/cli", appUrl),
"Then open the url in your browser (Or just press ENTER) and paste the code:",
tui.Link(authURL),

Check failure on line 81 in cmd/auth.go

View workflow job for this annotation

GitHub Actions / Build and Test (blacksmith-4vcpu-ubuntu-2204)

non-constant format string in call to github.com/agentuity/go-common/tui.Link
tui.Muted("This code will expire in 60 seconds"),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same vet error – non-constant format string in tui.Link.

The authentication banner fails the build for the same reason:

-			"Then open the url in your browser (Or just press ENTER) and paste the code:",
-			tui.Link(authURL),
+			"Then open the url in your browser (or just press ENTER) and paste the code:",
+			tui.Link("%s", authURL),

Apply the change to unblock CI.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
authURL := fmt.Sprintf("%s/auth/cli", appUrl)
body := tui.Paragraph(
"Copy the following code:",
tui.Bold(otp),
"Then open the url in your browser and paste the code:",
tui.Link("%s/auth/cli", appUrl),
"Then open the url in your browser (Or just press ENTER) and paste the code:",
tui.Link(authURL),
tui.Muted("This code will expire in 60 seconds"),
)
authURL := fmt.Sprintf("%s/auth/cli", appUrl)
body := tui.Paragraph(
"Copy the following code:",
tui.Bold(otp),
"Then open the url in your browser (or just press ENTER) and paste the code:",
tui.Link("%s", authURL),
tui.Muted("This code will expire in 60 seconds"),
)
🧰 Tools
🪛 GitHub Check: Build and Test (blacksmith-4vcpu-ubuntu-2204)

[failure] 81-81:
non-constant format string in call to github.com/agentuity/go-common/tui.Link

🪛 golangci-lint (1.64.8)

81-81: printf: non-constant format string in call to github.com/agentuity/go-common/tui.Link

(govet)

🪛 GitHub Actions: Go Build and Test

[error] 81-81: non-constant format string in call to github.com/agentuity/go-common/tui.Link

🤖 Prompt for AI Agents
In cmd/auth.go around lines 74 to 83, the call to tui.Link uses a non-constant
format string causing a vet error and build failure. To fix this, replace the
dynamic string passed to tui.Link with a constant string or refactor the code to
avoid passing a formatted string directly. This change will unblock the CI
build.


tui.ShowBanner("Login to Agentuity", body, false)

tui.ShowSpinner("Waiting for login to complete...", func() {
go util.PromptBrowserOpen(logger, authURL)

authResult, err := auth.PollForLoginCompletion(ctx, logger, apiUrl, otp)
if err != nil {
if isCancelled(ctx) {
Expand Down Expand Up @@ -218,6 +222,9 @@
},
}




func init() {
rootCmd.AddCommand(authCmd)
authCmd.AddCommand(authLoginCmd)
Expand Down
42 changes: 41 additions & 1 deletion internal/util/browser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package util

import (
"bufio"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -164,7 +165,7 @@
}
if !skip {
if berr := browser.OpenURL(u.String()); berr != nil {
returnErr = fmt.Errorf("failed to open browser: %s", err)
returnErr = fmt.Errorf("failed to open browser: %w", berr)
return
}
}
Expand All @@ -189,3 +190,42 @@

return returnErr
}

// PromptBrowserOpen prompts the user to press Enter to open a browser to the given URL.
// It handles display detection on Linux and provides appropriate user feedback.
func PromptBrowserOpen(logger interface{ Error(string, ...interface{}) }, url string) {
var skipOpen bool
if runtime.GOOS == "linux" {
// if we don't have a display, we can't open a browser most likely
if _, ok := os.LookupEnv("DISPLAY"); !ok {
skipOpen = true
}
}

fmt.Println()
if skipOpen {
fmt.Print(tui.Secondary("Press Enter to continue, or Ctrl+C to skip: "))
} else {
fmt.Print(tui.Secondary("Press Enter to open browser, or Ctrl+C to skip: "))
}

reader := bufio.NewReader(os.Stdin)
reader.ReadLine()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ignored error from ReadLine may hide I/O issues.

reader.ReadLine() returns (line, isPrefix, err) – you’re discarding err.
At minimum, capture and log/ignore io.EOF explicitly to avoid silent failures in unusual terminals (e.g., piped input).

Example quick fix:

-	reader := bufio.NewReader(os.Stdin)
-	reader.ReadLine()
+	reader := bufio.NewReader(os.Stdin)
+	if _, _, err := reader.ReadLine(); err != nil && !errors.Is(err, io.EOF) {
+		logger.Error("Error reading stdin: %v", err)
+		return
+	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if skipOpen {
fmt.Print(tui.Secondary("Press Enter to continue, or Ctrl+C to skip: "))
} else {
fmt.Print(tui.Secondary("Press Enter to open browser, or Ctrl+C to skip: "))
}
reader := bufio.NewReader(os.Stdin)
reader.ReadLine()
if skipOpen {
fmt.Print(tui.Secondary("Press Enter to continue, or Ctrl+C to skip: "))
} else {
fmt.Print(tui.Secondary("Press Enter to open browser, or Ctrl+C to skip: "))
}
reader := bufio.NewReader(os.Stdin)
if _, _, err := reader.ReadLine(); err != nil && !errors.Is(err, io.EOF) {
logger.Error("Error reading stdin: %v", err)
return
}
🤖 Prompt for AI Agents
In internal/util/browser.go around lines 206 to 214, the error returned by
reader.ReadLine() is ignored, which can hide I/O issues. Modify the code to
capture the error returned by ReadLine(), then explicitly check if the error is
io.EOF and handle it gracefully; for other errors, log or handle them
appropriately to avoid silent failures.

if !skipOpen {
if err := browser.OpenURL(url); err != nil {
logger.Error("Failed to open browser: %v", err)
} else {
// Clear previous line and move cursor up to remove the "Press Enter..." prompt
fmt.Print("\r\033[K\033[A\r\033[K")
tui.ShowSuccess("Browser opened!")
fmt.Println()
}
} else {
// Clear the prompt and show the URL for manual opening (and the loading spinner)
fmt.Print("\r\033[K")
fmt.Println(tui.Muted("Please visit the URL manually:"))
fmt.Println(tui.Link(url))

Check failure on line 228 in internal/util/browser.go

View workflow job for this annotation

GitHub Actions / Build and Test (blacksmith-4vcpu-ubuntu-2204)

non-constant format string in call to github.com/agentuity/go-common/tui.Link
fmt.Println()
Comment on lines +225 to +229
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

tui.Link called with a dynamic format string triggers vet failure.

go vet (and your pipeline) flags fmt.Println(tui.Link(url)) because url is treated as a format string and may contain % tokens. Pass a constant format instead:

-		fmt.Println(tui.Link(url))
+		fmt.Println(tui.Link("%s", url))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Clear the prompt and show the URL for manual opening (and the loading spinner)
fmt.Print("\r\033[K")
fmt.Println(tui.Muted("Please visit the URL manually:"))
fmt.Println(tui.Link(url))
fmt.Println()
// Clear the prompt and show the URL for manual opening (and the loading spinner)
fmt.Print("\r\033[K")
fmt.Println(tui.Muted("Please visit the URL manually:"))
- fmt.Println(tui.Link(url))
+ fmt.Println(tui.Link("%s", url))
fmt.Println()
🧰 Tools
🪛 GitHub Check: Build and Test (blacksmith-4vcpu-ubuntu-2204)

[failure] 228-228:
non-constant format string in call to github.com/agentuity/go-common/tui.Link

🪛 golangci-lint (1.64.8)

228-228: printf: non-constant format string in call to github.com/agentuity/go-common/tui.Link

(govet)

🤖 Prompt for AI Agents
In internal/util/browser.go around lines 225 to 229, the call to tui.Link with
url as a dynamic string causes go vet to fail because url may contain percent
signs interpreted as format verbs. To fix this, change the call to pass a
constant format string and url as an argument, ensuring tui.Link treats url as
data, not a format string.

}
}
Loading