Skip to content

Commit be9edcb

Browse files
Stop suggesting start --dry-run when lint errors block import.
Dry runs go through the same lint gate as real imports, so the lint-blocked remediation and next_steps pointed at a command that could not succeed. Blocked lint now suggests re-running lint after fixing errors instead. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9e93a49 commit be9edcb

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

internal/import/d1/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
const (
2525
wranglerMissingRemediation = "Install wrangler, use npx wrangler d1 export, or pass --input if you already have a dump."
2626
pgloaderInstallRemediation = "Install pgloader (brew install pgloader on macOS; see https://pgloader.readthedocs.io/en/latest/install.html for other platforms)"
27-
lintBlockedRemediation = "Fix lint errors or run `pscale import d1 lint` for details; use `import d1 start --dry-run` for a read-only preview"
27+
lintBlockedRemediation = "Fix the reported lint errors, then re-run; `pscale import d1 lint` shows details. Import (including --dry-run) is blocked until lint passes"
2828
)
2929

3030
type MigrationError struct {

internal/import/d1/lint.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,21 @@ func isJSONText(col ColumnSchema) bool {
186186

187187
// LintNextSteps returns agent next steps based on lint results.
188188
func LintNextSteps(result *LintResult) []NextStep {
189-
steps := []NextStep{
189+
input := filepath.Base(result.InputPath)
190+
if result.ErrorCount > 0 {
191+
return []NextStep{{
192+
Command: "pscale import d1 lint --input " + input,
193+
Reason: "Re-run lint after fixing the reported errors; import (including --dry-run) is blocked until lint passes",
194+
}}
195+
}
196+
return []NextStep{
190197
{
191-
Command: "pscale import d1 start <database> --input " + filepath.Base(result.InputPath) + " --dry-run",
198+
Command: "pscale import d1 start <database> --input " + input + " --dry-run",
192199
Reason: "Preview import plan and get a migration ID",
193200
},
194-
}
195-
if result.ErrorCount == 0 {
196-
steps = append(steps, NextStep{
197-
Command: "pscale import d1 start <database> --input " + filepath.Base(result.InputPath),
201+
{
202+
Command: "pscale import d1 start <database> --input " + input,
198203
Reason: "Run import after lint passes",
199-
})
204+
},
200205
}
201-
return steps
202206
}

internal/import/d1/lint_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ func TestLint(t *testing.T) {
9292
}
9393
}
9494

95+
func TestLintNextStepsBlockedOnErrorsDoesNotSuggestStart(t *testing.T) {
96+
blocked := &LintResult{InputPath: "/tmp/export.sql", ErrorCount: 1}
97+
steps := LintNextSteps(blocked)
98+
if len(steps) != 1 {
99+
t.Fatalf("steps = %d, want 1", len(steps))
100+
}
101+
if !strings.Contains(steps[0].Command, "import d1 lint") {
102+
t.Fatalf("blocked next step should re-run lint, got %q", steps[0].Command)
103+
}
104+
105+
clean := &LintResult{InputPath: "/tmp/export.sql"}
106+
steps = LintNextSteps(clean)
107+
if len(steps) != 2 {
108+
t.Fatalf("steps = %d, want 2", len(steps))
109+
}
110+
for _, step := range steps {
111+
if !strings.Contains(step.Command, "import d1 start") {
112+
t.Fatalf("clean next steps should suggest start, got %q", step.Command)
113+
}
114+
}
115+
}
116+
95117
func TestPlan(t *testing.T) {
96118
plan, err := Plan(PlanOptions{
97119
InputPath: testFixture(t),

0 commit comments

Comments
 (0)