{"record":{"id":"1f0db41be42a39e3","repo":"pulumi/pulumi","slug":"creating-context-w","errorCode":null,"errorMessage":"creating context: %w","messagePattern":"creating context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/pulumi/policyx/server.go","lineNumber":302,"sourceCode":"\n\tinfo := pulumi.RunInfo{\n\t\tStack:        req.Stack,\n\t\tProject:      req.Project,\n\t\tOrganization: req.Organization,\n\n\t\tRootDirectory: root,\n\n\t\tMonitorAddr: \"\",\n\t\tEngineAddr:  srv.handshake.EngineAddress,\n\n\t\tConfig:           req.Config,\n\t\tConfigSecretKeys: req.ConfigSecretKeys,\n\t\tDryRun:           req.DryRun,\n\t\tParallel:         1,\n\t}\n\tpctx, err := pulumi.NewContext(context.Background(), info)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating context: %w\", err)\n\t}\n\n\tsrv.stacktags = req.Tags\n\n\tsrv.policyPack, err = srv.policyPackFactory(pctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create policy pack: %w\", err)\n\t}\n\n\treturn &pulumirpc.AnalyzerStackConfigureResponse{}, nil\n}\n\nfunc (srv *analyzerServer) Configure(ctx context.Context, req *pulumirpc.ConfigureAnalyzerRequest) (*pbempty.Empty,\n\terror,\n) {\n\tconf := map[string]PolicyConfig{}\n\tfor k, v := range req.PolicyConfig {\n\t\tdata, err := v.GetProperties().MarshalJSON()","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/pulumi/policyx/server.go#L284-L320","documentation":"ConfigureStack builds a pulumi.RunInfo from the stack configuration request and calls pulumi.NewContext to create the SDK context for the policy pack. If NewContext fails (e.g. invalid RunInfo), the error is wrapped with 'creating context: %w'. This means the policy pack server could not initialize the Pulumi context that policies receive.","triggerScenarios":"pulumi.NewContext returns an error when building the context from the AnalyzerStackConfigureRequest fields (Stack, Project, Organization, Config, EngineAddress from the handshake).","commonSituations":"A nil or malformed handshake leaving EngineAddress empty in RunInfo; engine sending a request with invalid stack/project metadata; SDK version mismatch where NewContext validation rejects the RunInfo.","solutions":["Read the wrapped cause (%w) in the error chain to see why NewContext rejected the RunInfo","Ensure Handshake ran first so srv.handshake.EngineAddress is populated","Align the pulumi Go SDK version used by the policy pack with the engine version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// sanity-check RunInfo before relying on server behavior\nif info.EngineAddr == \"\" { log.Println(\"warning: empty engine address\") }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var ctxErr error\n    errors.As(err, &ctxErr) // unwrap 'creating context' cause\n    return fmt.Errorf(\"policy pack context setup failed: %w\", err)\n}","preventionTips":["Ensure Handshake precedes ConfigureStack so RunInfo is complete","Keep sdk/go in the policy pack aligned with the CLI","Log the unwrapped cause for diagnostics"],"tags":["go","policy","context"],"backgroundTag":"context-creation-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}