{"record":{"id":"ccbaf42f83bdc142","repo":"GoogleContainerTools/skaffold","slug":"getting-run-context-w-ccbaf4","errorCode":null,"errorMessage":"getting run context: %w","messagePattern":"getting run context: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/skaffold/app/cmd/runner.go","lineNumber":97,"sourceCode":"\nfunc runContext(ctx context.Context, out io.Writer, opts config.SkaffoldOptions) (*runcontext.RunContext, []util.VersionedConfig, error) {\n\tcfgSet, err := withFallbackConfig(ctx, out, opts, parser.GetConfigSet)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tsetDefaultRendererAndDeployer(cfgSet)\n\n\tif err := validation.Process(cfgSet, validation.GetValidationOpts(opts)); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid skaffold config: %w\", err)\n\t}\n\tvar configs []util.VersionedConfig\n\tfor _, cfg := range cfgSet {\n\t\tconfigs = append(configs, cfg.SkaffoldConfig)\n\t}\n\n\trunCtx, err := runcontext.GetRunContext(ctx, opts, configs)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"getting run context: %w\", err)\n\t}\n\n\tif err := validation.ProcessWithRunContext(ctx, runCtx); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid skaffold config: %w\", err)\n\t}\n\n\treturn runCtx, configs, nil\n}\n\n// withFallbackConfig will try to automatically generate a config if root `skaffold.yaml` file does not exist.\nfunc withFallbackConfig(ctx context.Context, out io.Writer, opts config.SkaffoldOptions, getCfgs func(context.Context, config.SkaffoldOptions) (parser.SkaffoldConfigSet, error)) (parser.SkaffoldConfigSet, error) {\n\tconfigs, err := getCfgs(ctx, opts)\n\tif err == nil {\n\t\treturn configs, nil\n\t}\n\tvar e sErrors.Error\n\tif errors.As(err, &e) && e.StatusCode() == proto.StatusCode_CONFIG_FILE_NOT_FOUND_ERR {\n\t\tif (opts.AutoCreateConfig || opts.AutoInit) && initializer.ValidCmd(opts) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/runner.go#L79-L115","documentation":"Fires in runContext when runcontext.GetRunContext fails while assembling the run context (pipelines, options, and configs) for a skaffold command. Wraps the run-context construction error, which is usually caused by inconsistent configuration (e.g. conflicting pipeline settings) after config parsing and validation succeeded.","triggerScenarios":"Any command creating a runner when runcontext.GetRunContext fails: invalid --profile name, incompatible command mode (e.g. using a deployer unsupported for `skaffold run`), bad kubecontext flags, or mismatched config for the requested pipeline mode.","commonSituations":"Passing -p with a profile name that does not exist; --kube-context pointing to a context not in kubeconfig; configs where the resolved deployer does not support the requested command (e.g. apply vs run).","solutions":["Read the wrapped cause after 'getting run context:' for the specific resolution failure","Verify profile names with `skaffold inspect profiles`","Confirm --kube-context matches an entry in kubectl config get-contexts","Remove conflicting flags (e.g. mutually exclusive run/apply options)"],"exampleFix":"// before\nskaffold run -p prod // profile 'prod' not defined\n// after\nskaffold run -p production # matches profile in skaffold.yaml","handlingStrategy":"validation","validationCode":"CONTEXT=$(kubectl config current-context)\nskaffold inspect profiles -f skaffold.yaml | grep -q \"$PROFILE\" || echo \"profile $PROFILE not defined\"\nkubectl config get-contexts | grep -q \"$CONTEXT\" || echo \"kubecontext $CONTEXT missing\"","typeGuard":null,"tryCatchPattern":"runCtx, configs, err := runContext(ctx, out, opts)\nif err != nil {\n\tvar runCtxErr = \"getting run context\"\n\tif strings.Contains(err.Error(), runCtxErr) {\n\t\treturn fmt.Errorf(\"check -p/--kube-context flags: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Confirm profile names with `skaffold inspect profiles` before using -p","Verify kube-context names exist in kubeconfig before passing --kube-context","Avoid combining flags unsupported for the command mode (run vs apply vs render)","Document required profiles in CI pipelines to prevent flag typos"],"tags":["skaffold","runcontext","profiles","configuration"],"backgroundTag":"run-context-resolution-failed","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"}