<#549 osctrl-api is not working> Issue created by ...
# osctrl
g
#549 osctrl-api is not working Issue created by zhuoyuan-liu It seems that osctrl-api is broken after this change: #507 I got the following error when calling
QueriesRunHandler
Copy code
2024/10/25 11:37:37 http: panic serving 127.0.0.1:60460: interface conversion: interface {} is nil, not handlers.contextValue |  
-- | --
  |   | 2024-10-25 13:37:37.165 | goroutine 83 [running]: |  
  |   | 2024-10-25 13:37:37.165 | net/http.(*conn).serve.func1() |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:1947 +0xb0 |  
  |   | 2024-10-25 13:37:37.165 | panic({0x904cc0?, 0x4000648990?}) |  
  |   | 2024-10-25 13:37:37.165 | runtime/panic.go:785 +0x124 |  
  |   | 2024-10-25 13:37:37.165 | <http://github.com/jmpsec/osctrl/api/handlers.(*HandlersApi).QueriesRunHandler(0x400045df00|github.com/jmpsec/osctrl/api/handlers.(*HandlersApi).QueriesRunHandler(0x400045df00>, {0xc6b0d8, 0x40000e41c0}, 0x4000412000) |  
  |   | 2024-10-25 13:37:37.165 | <http://github.com/jmpsec/osctrl/api/handlers@v0.4.0/queries.go:87|github.com/jmpsec/osctrl/api/handlers@v0.4.0/queries.go:87> +0x12e8 |  
  |   | 2024-10-25 13:37:37.165 | net/http.HandlerFunc.ServeHTTP(0x400047e000?, {0xc6b0d8?, 0x40000e41c0?}, 0xc5f2a0?) |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:2220 +0x38 |  
  |   | 2024-10-25 13:37:37.165 | main.osctrlAPIService.handlerAuthCheck.func22({0xc6b0d8, 0x40000e41c0}, 0x400047e000) |  
  |   | 2024-10-25 13:37:37.165 | osctrl/api/auth.go:58 +0x364 |  
  |   | 2024-10-25 13:37:37.165 | net/http.HandlerFunc.ServeHTTP(0x40000e40e0?, {0xc6b0d8?, 0x40000e41c0?}, 0x40006e5b10?) |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:2220 +0x38 |  
  |   | 2024-10-25 13:37:37.165 | net/http.(*ServeMux).ServeHTTP(0x10?, {0xc6b0d8, 0x40000e41c0}, 0x400047e000) |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:2747 +0x1b4 |  
  |   | 2024-10-25 13:37:37.165 | net/http.serverHandler.ServeHTTP({0xc676e0?}, {0xc6b0d8?, 0x40000e41c0?}, 0x6?) |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:3210 +0xbc |  
  |   | 2024-10-25 13:37:37.165 | net/http.(*conn).serve(0x40000f2480, {0xc6c9d0, 0x40007aab40}) |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:2092 +0x4fc |  
  |   | 2024-10-25 13:37:37.165 | created by net/http.(*Server).Serve in goroutine 1 |  
  |   | 2024-10-25 13:37:37.165 | net/http/server.go:3360 +0x3dc
I went through some recent changes and found that the osctrl-api is in a bad position, where no components are using it. osctrl-admin and osctrl-cli are calling database directly. Is there any plan to reduce the code duplication and make sure all the API requests would go through the osctrl-api? It also reduces the risk for direct access to the database. Also, for organizing the code, I would suggest that we move all the binary main.go to
/cmd/osctrl-components
and keep only one go.mod file. It helps us find all implementation and references. jmpsec/osctrl