{"record":{"id":"1ae51d79ac33b426","repo":"GoogleContainerTools/skaffold","slug":"unknown-phase-v-not-found-in-handler-state","errorCode":null,"errorMessage":"unknown phase %v not found in handler state","messagePattern":"unknown phase (.+?) not found in handler state","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/event/event.go","lineNumber":808,"sourceCode":"\nfunc emptyStatusCheckState() *proto.StatusCheckState {\n\treturn &proto.StatusCheckState{\n\t\tStatus:     NotStarted,\n\t\tResources:  map[string]string{},\n\t\tStatusCode: proto.StatusCode_OK,\n\t}\n}\n\nfunc AutoTriggerDiff(name string, val bool) (bool, error) {\n\tswitch name {\n\tcase \"build\":\n\t\treturn val != handler.getState().BuildState.AutoTrigger, nil\n\tcase \"sync\":\n\t\treturn val != handler.getState().FileSyncState.AutoTrigger, nil\n\tcase \"deploy\":\n\t\treturn val != handler.getState().DeployState.AutoTrigger, nil\n\tdefault:\n\t\treturn false, fmt.Errorf(\"unknown phase %v not found in handler state\", name)\n\t}\n}\n\n// BuildSequenceFailed notifies that the build sequence has failed.\nfunc BuildSequenceFailed(err error) {\n\taiErr := sErrors.ActionableErr(handler.cfg, constants.Build, err)\n\thandler.stateLock.Lock()\n\thandler.state.BuildState.StatusCode = aiErr.ErrCode\n\thandler.stateLock.Unlock()\n}\n\nfunc InititializationFailed(err error) {\n\thandler.handle(&proto.Event{\n\t\tEventType: &proto.Event_TerminationEvent{\n\t\t\tTerminationEvent: &proto.TerminationEvent{\n\t\t\t\tStatus: Failed,\n\t\t\t\tErr:    sErrors.ActionableErr(handler.cfg, constants.Init, err),\n\t\t\t},","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/event/event.go#L790-L826","documentation":"AutoTriggerDiff computes whether an auto-trigger setting changed for a given phase (build/sync/deploy). If the phase name argument is anything other than those three, it returns 'unknown phase %v not found in handler state'. This is an internal invariant violation: the caller passed an unsupported phase identifier.","triggerScenarios":"executeAutoTrigger calls AutoTriggerDiff with a phase string not in {\"build\",\"sync\",\"deploy\"} — typically after adding a new phase to the state handler without updating this switch.","commonSituations":"Skaffold source modification adding a new pipeline phase; plugin or fork code calling AutoTriggerDiff with a custom phase name; typo in a phase constant passed through.","solutions":["Use only the supported phase names: \"build\", \"sync\", or \"deploy\"","If adding a new phase in a fork, extend the switch in AutoTriggerDiff (and the corresponding handler state) to cover it","Check upstream skaffold for updates if a new phase was introduced and this branch is stale"],"exampleFix":"// before\nAutoTriggerDiff(cfg, \"deployStatus\", val)\n// after\nAutoTriggerDiff(cfg, \"deploy\", val)","handlingStrategy":"validation","validationCode":"var validPhases = map[string]bool{\"build\": true, \"sync\": true, \"deploy\": true}\nif !validPhases[phase] {\n    return fmt.Errorf(\"unsupported phase %q for AutoTriggerDiff\", phase)\n}","typeGuard":"func isKnownPhase(name string) bool {\n    switch name {\n    case \"build\", \"sync\", \"deploy\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"if diff, err := AutoTriggerDiff(cfg, phase, val); err != nil {\n    if strings.Contains(err.Error(), \"unknown phase\") {\n        log.Debugf(\"no auto-trigger diff for phase %q\", phase)\n        return nil\n    }\n    return err\n}","preventionTips":["Only pass the build, sync, or deploy phase identifiers","Add unit tests covering every phase name routed to AutoTriggerDiff","When adding a new phase, update AutoTriggerDiff in the same change","Use a typed phase enum instead of raw strings in forks"],"tags":["internal","auto-trigger","programmer-error"],"backgroundTag":"invalid-enum-value","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"}