{"record":{"id":"4d65b5171978bfd0","repo":"kubernetes/kops","slug":"error-building-context-w","errorCode":null,"errorMessage":"error building context: %w","messagePattern":"error building context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/command.go","lineNumber":379,"sourceCode":"\n\tvar target fi.NodeupTarget\n\n\tswitch c.Target {\n\tcase \"direct\":\n\t\ttarget = &local.LocalTarget{\n\t\t\tCacheDir: c.CacheDir,\n\t\t\tCloud:    cloud,\n\t\t}\n\tcase \"dryrun\":\n\t\tassetBuilder := assets.NewAssetBuilder(vfs.Context, nil, false)\n\t\ttarget = fi.NewNodeupDryRunTarget(assetBuilder, out)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported target type %q\", c.Target)\n\t}\n\n\tcontext, err := fi.NewNodeupContext(ctx, target, keyStore, &bootConfig, &nodeupConfig, taskMap)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building context: %w\", err)\n\t}\n\n\tvar options fi.RunTasksOptions\n\toptions.InitDefaults()\n\n\t// Return rather than exit, so that the retry loop in cmd/nodeup gets to run:\n\t// kops-configuration.service is Type=oneshot, so a bootstrap that exits here is never\n\t// retried and the node never joins the cluster.\n\terr = context.RunTasks(options)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error running tasks: %w\", err)\n\t}\n\n\terr = target.Finish(taskMap)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error closing target: %w\", err)\n\t}\n","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/command.go#L361-L397","documentation":"After building the target, Run() constructs a fi.NodeupContext holding the target, keystore, boot config, nodeup config, and task map. If NewNodeupContext fails (invalid or inconsistent inputs, nil/invalid keystore, bad config structure), the error is wrapped as \"error building context\". Bootstrap cannot proceed without a valid context.","triggerScenarios":"fi.NewNodeupContext(ctx, target, keyStore, &bootConfig, &nodeupConfig, taskMap) returns an error — e.g. invalid boot/nodeup config fields, a nil or unusable KeyStore, or an inconsistent combination of the passed objects.","commonSituations":"Truncated or corrupt nodeup.conf / boot config dropped on the node by kops; keyStore never set because ConfigStore.Keypairs was empty in an unexpected code path; version mismatch where a newer nodeup expects config fields absent in an older-rendered config.","solutions":["Read the wrapped error (%w) for the specific validation that failed","Verify the nodeup bootstrap and nodeup config files on the node are complete and freshly rendered (`kops update cluster --yes` then re-provision)","Ensure ConfigStore.Keypairs points to a valid keystore VFS path readable from the node","Match nodeup binary version to the kops version that generated the config"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := nodeupCmd.Run(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error building context\") {\n        log.Fatalf(\"NodeupContext build failed: %v — verify nodeup.conf and keystore paths\", err)\n    }\n    return err\n}","preventionTips":["Ensure bootstrap/nodeup config files are fully written before starting kops-configuration.service (use systemd After=/Requires=)","Keep ConfigStore.Keypairs set to a valid, node-readable VFS path","Match nodeup version to the kops version that rendered the config","Validate config JSON parses before launching nodeup"],"tags":["nodeup","context","config-validation"],"backgroundTag":"nodeup-context-build-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}