{"record":{"id":"1feb3345c8bf776a","repo":"projectdiscovery/nuclei","slug":"payloads-not-defined-and-cannot-be-updated","errorCode":null,"errorMessage":"payloads not defined and cannot be updated","messagePattern":"payloads not defined and cannot be updated","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/javascript/js.go","lineNumber":218,"sourceCode":"\n\t\t\treturn gojs.RegisterFuncWithSignature(runtime, gojs.FuncOpts{\n\t\t\t\tName: \"updatePayload\",\n\t\t\t\tSignatures: []string{\n\t\t\t\t\t\"updatePayload(string, interface{})\",\n\t\t\t\t},\n\t\t\t\tDescription: \"update/override any payload from init code. this function is available in init code block only\",\n\t\t\t\tFuncDecl: func(varname string, Value any) error {\n\t\t\t\t\tif request.Payloads == nil {\n\t\t\t\t\t\trequest.Payloads = make(map[string]interface{})\n\t\t\t\t\t}\n\t\t\t\t\tif request.generator != nil {\n\t\t\t\t\t\trequest.Payloads[varname] = Value\n\t\t\t\t\t\trequest.generator, err = generators.New(request.Payloads, request.AttackType.Value, request.options.TemplatePath, options.Catalog, options.Options.AttackType, options.Options)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"payloads not defined and cannot be updated\")\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\topts.Cleanup = func(runtime *goja.Runtime) {\n\t\t\t_ = runtime.GlobalObject().Delete(\"set\")\n\t\t\t_ = runtime.GlobalObject().Delete(\"updatePayload\")\n\t\t}\n\n\t\targs := compiler.NewExecuteArgs()\n\t\tallVars := generators.MergeMaps(options.Variables.GetAll(), options.Options.Vars.AsMap(), request.options.Constants)\n\t\t// proceed with whatever args we have\n\t\targs.Args, _, _ = request.evaluateArgs(allVars, options, true)\n\n\t\tresult, err := request.options.JsCompiler.ExecuteWithOptions(context.Background(), initCompiled, args, opts)\n\t\tif err != nil {\n\t\t\treturn errkit.Newf(\"could not execute pre-condition: %s\", err)","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/javascript/js.go#L200-L236","documentation":"Error \"payloads not defined and cannot be updated\" thrown in projectdiscovery/nuclei.","triggerScenarios":"Thrown at pkg/protocols/javascript/js.go:218 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}