{"record":{"id":"c0dc0adb2c957b7b","repo":"GoogleContainerTools/skaffold","slug":"exiting-dev-mode-because-test-failed-after-first-b","errorCode":null,"errorMessage":"exiting dev mode because test failed after first build: %w","messagePattern":"exiting dev mode because test failed after first build: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/dev.go","lineNumber":300,"sourceCode":"\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\tendTrace()\n\t\treturn fmt.Errorf(\"exiting dev mode because first build failed: %w\", err)\n\t}\n\t// First test\n\tif r.runCtx.IsTestPhaseActive() {\n\t\terr = r.Test(ctx, out, bRes)\n\t\tfor ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; err = r.Test(ctx, out, bRes) {\n\t\t\tlog.Entry(ctx).Warnf(\"Failed to run tests :%v, please fix the error and press any key to continue.\", err)\n\t\t\terrT := term.WaitForKeyPress()\n\t\t\tif errT != nil {\n\t\t\t\treturn errT\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\tevent.DevLoopFailedInPhase(r.devIteration, constants.Build, err)\n\t\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\t\tendTrace()\n\t\t\treturn fmt.Errorf(\"exiting dev mode because test failed after first build: %w\", err)\n\t\t}\n\t}\n\n\tdefer r.deployer.GetLogger().Stop()\n\tdefer r.deployer.GetDebugger().Stop()\n\n\t// Logs should be retrieved up to just before the deploy\n\tr.deployer.GetLogger().SetSince(time.Now())\n\n\t// First render\n\tmanifests, err := r.Render(ctx, out, r.Builds, false)\n\tfor ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; manifests, err = r.Render(ctx, out, r.Builds, false) {\n\t\tlog.Entry(ctx).Warnf(\"Failed to render :%v, please fix the error and press any key to continue.\", err)\n\t\terrT := term.WaitForKeyPress()\n\t\tif errT != nil {\n\t\t\treturn errT\n\t\t}\n\t}","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/dev.go#L282-L318","documentation":"In `skaffold dev`, if the first-iteration test phase fails (and KeepRunningOnFailure is not enabled, or the retry loop exits), dev mode terminates since tests after the first build are treated as blocking. The test error is wrapped with %w.","triggerScenarios":"Dev(): after first build, r.Test fails; if not continuing via Opts.KeepRunningOnFailure the loop ends with err != nil and dev exits with this message.","commonSituations":"Unit tests failing on first run (missing test fixtures, wrong container-test command); container-structure-test failing; test image build issues.","solutions":["Fix the failing test reported by the wrapped error","Re-run with --keep-running-on-failure to stay in dev mode while iterating on tests","Skip tests temporarily with --skip-tests while debugging","Run the test command manually to reproduce"],"exampleFix":"// before\nskaffold dev\n// after — stay in dev loop on test failure\nskaffold dev --keep-running-on-failure","handlingStrategy":"try-catch","validationCode":"// run tests once outside dev to pre-validate\nif (runCmd('skaffold test').code !== 0) exit('tests fail before dev start')","typeGuard":"function testsConfigured(cfg) {\n  return cfg.test == null || (Array.isArray(cfg.test) && cfg.test.every(t => typeof t.image === 'string'))\n}","tryCatchPattern":"err := r.Dev(ctx, out, dryRun)\nif err != nil && strings.Contains(err.Error(), \"test failed after first build\") {\n    log.Warnf(\"tests failing: %v — fix or use --keep-running-on-failure\", err)\n}","preventionTips":["Keep container-test commands runnable locally","Run `skaffold test` in CI before dev workflows","Use --skip-tests temporarily only when tests are known-broken","Ensure test images and fixtures are built/present"],"tags":["dev-loop","test","fatal"],"backgroundTag":"initial-build-failure","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}