{"record":{"id":"fc22fd5dc1ca5147","repo":"owasp-amass/amass","slug":"failed-to-create-the-api-server","errorCode":null,"errorMessage":"failed to create the API server","messagePattern":"failed to create the API server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"engine/engine.go","lineNumber":56,"sourceCode":"\t\tl = slog.New(slog.NewTextHandler(os.Stdout, nil))\n\t}\n\n\treg := registry.NewRegistry(l)\n\tmgr := sessions.NewManager(l, reg)\n\tif mgr == nil {\n\t\treturn nil, errors.New(\"failed to create the session manager\")\n\t}\n\n\tdis := dispatcher.NewDispatcher(l, reg, mgr)\n\tif err := plugins.LoadAndStartPlugins(reg); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsrv, err := server.NewServer(l, dis, mgr)\n\tif err != nil || srv == nil {\n\t\tdis.Shutdown()\n\t\tmgr.Shutdown()\n\t\treturn nil, errors.New(\"failed to create the API server\")\n\t}\n\n\tch := make(chan error, 1)\n\tgo func(errch chan error) { errch <- srv.Start() }(ch)\n\n\tt := time.NewTimer(3 * time.Second)\n\tdefer t.Stop()\n\n\tselect {\n\tcase err := <-ch:\n\t\tif err != nil {\n\t\t\t_ = srv.Shutdown()\n\t\t\tdis.Shutdown()\n\t\t\tmgr.Shutdown()\n\t\t\treturn nil, err\n\t\t}\n\tcase <-t.C:\n\t\t// If the server does not return an error within 3 seconds, we assume it started successfully","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/engine.go#L38-L74","documentation":"After building the dispatcher, NewEngine calls server.NewServer to create the API server. If it errors or returns nil, the engine shuts down the dispatcher and session manager and fails startup with this error.","triggerScenarios":"server.NewServer(l, dis, mgr) returns an error or a nil server during NewEngine, e.g. invalid configuration for the HTTP server, port binding setup failure surfaced at construction, or internal nil checks.","commonSituations":"Bad API server configuration (invalid address/port values), a broken build of the api/server package, or version drift between the server constructor signature and its caller.","solutions":["Check the API server configuration (address, port, TLS settings) for invalid values","Look at any log output from server.NewServer for the root cause before this generic error","Verify the server package builds and its constructor matches the call site","Ensure the port is free and not blocked by permissions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if cfg.APIAddr == \"\" || cfg.APIPort == 0 {\n    return errors.New(\"API server address/port must be configured\")\n}","typeGuard":null,"tryCatchPattern":"eng, err := NewEngine(cfg)\nif err != nil {\n    log.Fatalf(\"engine initialization failed: %v\", err)\n}\n// note: NewEngine already shuts down dispatcher and manager on this error","preventionTips":["Validate API server configuration values before calling NewEngine","Check for port availability/permissions before startup","Keep api/server and engine packages version-aligned"],"tags":["engine","api-server","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}