Conversation
…, root registration - Extend authconfig.Config with SimAPIKey field for sim_api_key in config.yaml - Add SimClient HTTP wrapper (cmd/sim/client.go) with X-Sim-Api-Key auth header and structured HTTP error handling (400/401/404/429/500) - Add SetSimClient/SimClientFromCmd to cmdutil for context-based client injection - Create sim parent command with PersistentPreRunE that resolves sim API key (--sim-api-key flag > DUNE_SIM_API_KEY env > config file) - Create stub evm/svm parent commands for future subcommands - Register sim command in cli/root.go init() - All commands annotated with skipAuth to bypass Dune API key requirement
PR SummaryMedium Risk Overview Introduces Written by Cursor Bugbot for commit 3ec8d83. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Sim's PersistentPreRunE overrides root's, breaking telemetry tracking
- Added cmdutil.SetStartTime call at the beginning of simPreRun to ensure start time is tracked for all sim subcommands.
Or push these changes by commenting:
@cursor push 6d2c3c3b2c
Preview (6d2c3c3b2c)
diff --git a/cmd/sim/sim.go b/cmd/sim/sim.go
--- a/cmd/sim/sim.go
+++ b/cmd/sim/sim.go
@@ -4,6 +4,7 @@
"fmt"
"os"
"strings"
+ "time"
"github.com/spf13/cobra"
@@ -43,6 +44,8 @@
// simPreRun resolves the Sim API key and stores a SimClient in the command context.
// Commands annotated with "skipSimAuth": "true" bypass this step.
func simPreRun(cmd *cobra.Command, _ []string) error {
+ cmdutil.SetStartTime(cmd, time.Now())
+
// Allow commands like `sim auth` to skip sim client creation.
if cmd.Annotations["skipSimAuth"] == "true" {
return nilComment @cursor review or bugbot run to trigger another review on this PR
| "Authenticate with a Sim API key via --sim-api-key, the DUNE_SIM_API_KEY environment\n" + | ||
| "variable, or by running `dune sim auth`.", | ||
| Annotations: map[string]string{"skipAuth": "true"}, | ||
| PersistentPreRunE: simPreRun, |
There was a problem hiding this comment.
Sim's PersistentPreRunE overrides root's, breaking telemetry tracking
Medium Severity
The sim command defines its own PersistentPreRunE, which in cobra (without EnableTraverseRunHooks) completely replaces the root command's PersistentPreRunE for all sim subcommands. The root's hook calls cmdutil.SetStartTime, which the root's PersistentPostRunE depends on for duration tracking. Since SetStartTime is never called for sim subcommands, StartTimeFromCmd returns a zero time.Time, causing time.Since(start) to produce a wildly incorrect duration sent to telemetry. The existing cmd/auth avoids this by using only the skipAuth annotation without defining its own PersistentPreRunE.




Add
dune sim authcommand for persisting a Sim API key via --api-key flag, DUNE_SIM_API_KEY env var, or interactive prompt. Wires up the sim command tree with SimClient, evm/svm parent commands, and registers sim in the root CLI.