pballester opened a new pull request, #9022:
URL: https://github.com/apache/devlake/pull/9022

   ### Summary
   
   All `plugins/org` API endpoints (`teams.csv`, `users.csv`, 
`user_account_mapping.csv`, `project_mapping.csv`) panic with a nil pointer 
dereference whenever route registration wins the race against plugin 
initialization — full diagnosis with startup-log evidence in #9021.
   
   `InitPlugins()` (the only thing that calls `PluginInit.Init()` in server 
mode) runs inside `pipelineServiceInit()`, while `registerPluginEndpoints` 
evaluates each plugin's `ApiResources()` independently. The org plugin returned 
**bound method values** (`p.handlers.GetTeam`), and Go captures the receiver at 
evaluation time — if `Init()` hasn't run yet, the router permanently holds 
handlers bound to a nil `*Handlers`. A pending DB migration at boot makes the 
bad ordering deterministic, which is why this bit several users after upgrades 
(#8590, #8271, #7957, #7219).
   
   This fix resolves `p.handlers` at **request time** via method expressions, 
returning a clean 500 with "org plugin is not initialized yet, please retry 
later" during the (brief) pre-init window instead of panicking forever after it.
   
   - `go build` / `go vet` / `gofmt` clean on the touched packages
   - New unit test `TestApiResourcesBeforeInitFailsGracefully` covers every org 
endpoint pre-init (panicked before this change, clean error now)
   - e2e tests unchanged (require `E2E_DB_URL`)
   
   A broader alternative would be moving `InitPlugins()` ahead of route 
registration in server startup — deliberately not done here to keep the change 
scoped to the affected plugin; happy to follow up if maintainers prefer that 
direction.
   
   ### Does this close any open issues?
   
   Closes #9021
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to