{"record":{"id":"8c09318d40b672c0","repo":"GoogleContainerTools/skaffold","slug":"finding-auto-activated-profiles-w","errorCode":null,"errorMessage":"finding auto-activated profiles: %w","messagePattern":"finding auto-activated profiles: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/profiles.go","lineNumber":49,"sourceCode":"\tkubectx \"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/kubernetes/context\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/parser/configlocations\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util\"\n\tskutil \"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util/stringslice\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/yaml\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/yamltags\"\n)\n\n// ApplyProfiles modifies the input skaffold configuration by the application\n// of a list of profiles, and returns the list of applied profiles.\nfunc ApplyProfiles(c *latest.SkaffoldConfig, fieldsOverrodeByProfile map[string]configlocations.YAMLOverrideInfo, opts cfg.SkaffoldOptions, namedProfiles []string) ([]string, map[string]configlocations.YAMLOverrideInfo, error) {\n\tbyName := profilesByName(c.Profiles)\n\n\tprofiles, contextSpecificProfiles, err := activatedProfiles(c.Profiles, opts, namedProfiles)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"finding auto-activated profiles: %w\", err)\n\t}\n\tfor _, name := range profiles {\n\t\tprofile, present := byName[name]\n\t\tif !present {\n\t\t\treturn nil, nil, fmt.Errorf(\"couldn't find profile %s\", name)\n\t\t}\n\n\t\tif err := applyProfile(c, fieldsOverrodeByProfile, profile); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"applying profile %q: %w\", name, err)\n\t\t}\n\t}\n\n\t// remove profiles section for run modes where profiles are already merged into the main pipeline\n\tswitch opts.Mode() {\n\tcase cfg.RunModes.Build, cfg.RunModes.Dev, cfg.RunModes.Deploy, cfg.RunModes.Debug, cfg.RunModes.Render, cfg.RunModes.Run, cfg.RunModes.Diagnose, cfg.RunModes.Delete:\n\t\tc.Profiles = nil\n\t}\n\treturn profiles, fieldsOverrodeByProfile, checkKubeContextConsistency(contextSpecificProfiles, opts.KubeContext, c.Deploy.KubeContext)","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/profiles.go#L31-L67","documentation":"While applying profiles to the skaffold config, ApplyProfiles first computes which profiles are auto-activated (by kube-context, env vars, commands, or gke flags). If that evaluation itself fails — e.g. a profile activation rule references an environment variable in a way that errors — the failure is wrapped as `finding auto-activated profiles: %w`. The inner error (visible after the colon) identifies the specific activation check that failed.","triggerScenarios":"skaffold.yaml defines `profiles.activation` with an `env` or `gke` criterion that cannot be evaluated (e.g. malformed kube-context comparison or an environment lookup failure), and auto-activation is enabled (default). Triggered via ApplyProfiles during any config-processing run mode (dev, run, build, render, diagnose).","commonSituations":"Profiles with activation env rules evaluated in shells/environments where the variable is missing or invalid; corrupt or unreadable kubeconfig causing context-based activation to fail; config files generated programmatically with malformed activation blocks.","solutions":["Read the wrapped inner error after the colon for the actual failing activation rule","Fix or remove the offending `activation` block in skaffold.yaml (env/context/command criteria)","Run with `--profile-auto-activation=false` or invoke the profile explicitly with `-p <name>` to bypass auto-activation","Validate the skaffold config with `skaffold diagnose` to surface activation problems"],"exampleFix":"# before (skaffold.yaml)\nprofiles:\n- name: staging\n  activation:\n  - env: INVALID~VAR=staging\n# after\nprofiles:\n- name: staging\n  activation:\n  - env: ENV=staging","handlingStrategy":"validation","validationCode":"for _, p := range cfg.Profiles {\n    for _, a := range p.Activation {\n        if a.Env != \"\" && !strings.Contains(a.Env, \"=\") {\n            return fmt.Errorf(\"profile %q has malformed env activation %q\", p.Name, a.Env)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"profiles, _, err := schema.ApplyProfiles(c, overrides, opts, named)\nif err != nil {\n    var inner error = errors.Unwrap(err)\n    log.Entry(context.Background()).Errorf(\"profile activation failed: %v (cause: %v)\", err, inner)\n    return err\n}","preventionTips":["Keep activation rules simple (single env/context/command criteria)","Run `skaffold diagnose` in CI to validate activation blocks","Use explicit `-p` profiles in CI instead of relying on auto-activation","Avoid env activation rules for variables not guaranteed in the runtime environment"],"tags":["skaffold","profiles","configuration","auto-activation"],"backgroundTag":"profile-activation-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"}