{"record":{"id":"9d99cea208867797","repo":"GoogleContainerTools/skaffold","slug":"getting-run-context-w","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/diagnose.go","lineNumber":109,"sourceCode":"\tif enableTemplating {\n\t\tif err := tags.ApplyTemplates(configs); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tbuf, err := yaml.MarshalWithSeparator(configs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshalling configuration: %w\", err)\n\t}\n\n\tout.Write(buf)\n\n\treturn nil\n}\n\nfunc printArtifactDiagnostics(ctx context.Context, out io.Writer, configs []schemaUtil.VersionedConfig) error {\n\trunCtx, err := getRunContext(ctx, opts, configs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting run context: %w\", err)\n\t}\n\ttagger, err := tag.NewTaggerMux(runCtx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting tagger: %w\", err)\n\t}\n\timageTags, err := deployutil.ImageTags(ctx, runCtx, tagger, out, runCtx.Artifacts())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting tags: %w\", err)\n\t}\n\tfor _, c := range configs {\n\t\tconfig := c.(*latest.SkaffoldConfig)\n\t\tfmt.Fprintln(out, \"Skaffold version:\", version.Get().GitCommit)\n\t\tfmt.Fprintln(out, \"Configuration version:\", config.APIVersion)\n\t\tfmt.Fprintln(out, \"Number of artifacts:\", len(config.Build.Artifacts))\n\t\tif err := diagnose.CheckArtifacts(ctx, runCtx, imageTags, out); err != nil {\n\t\t\treturn fmt.Errorf(\"running diagnostic on artifacts: %w\", err)\n\t\t}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/diagnose.go#L91-L127","documentation":"Wraps a getRunContext failure in printArtifactDiagnostics during `skaffold diagnose`. getRunContext assembles the full run context (parsed configs, kube context, default repo, tagger inputs); failures usually mean the skaffold.yaml could not be loaded/validated or cluster context resolution failed, so artifact diagnostics cannot proceed.","triggerScenarios":"`skaffold diagnose` calls getRunContext(ctx, opts, configs) and it errors — typically an invalid or missing skaffold.yaml section, unresolvable --kube-context, or invalid --default-repo flag.","commonSituations":"Running diagnose outside a directory with skaffold.yaml; malformed config failing validation; specifying a kube-context that does not exist in kubeconfig; profile referencing missing base config.","solutions":["Fix the wrapped error from getRunContext — usually a skaffold.yaml validation message; run `skaffold diagnose` from the project root","Validate config with `skaffold diagnose` flags like --profile off, or `skaffold run --dry-run` style checks","Ensure the kube-context given via --kube-context exists (kubectl config get-contexts)","Remove or fix profiles/overrides referencing missing files"],"exampleFix":"// before\nskaffold diagnose --kube-context prod-ctx   # context deleted\n// after\nkubectl config get-contexts\nskaffold diagnose --kube-context staging-ctx","handlingStrategy":"validation","validationCode":"# preconditions before diagnose\nkubectl config get-contexts            # kube-context exists?\ntest -f skaffold.yaml && echo \"config present\"\n# validate config parses\nskaffold diagnose --profile <none> 2>&1 | head -5","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if strings.Contains(err.Error(), \"getting run context:\") {\n        // re-run with explicit flags: --kube-context, --default-repo\n    }\n}","preventionTips":["Run diagnose from the project root containing skaffold.yaml","Ensure the --kube-context exists in kubeconfig","Validate profiles reference existing base configs and files"],"tags":["skaffold","config","diagnostics"],"backgroundTag":"invalid-skaffold-config","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"}