mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
`handleSave` was 280 lines that parsed stdio JSON, filtered credentials, resolved half a dozen conditional flags, built the request body, and then made the network call, all inside one try block reading ten closure variables. None of it could be tested without rendering the whole modal and pressing Save. The payload building moves to `editServerPayload.ts` as `buildEditServerPayload`, mirroring the `createServerPayload.ts` module that already sits beside it: a pure function taking form values, UI state, and the server being edited, and returning a tagged union rather than throwing. The six ways it can fail are now values in that union, and the component maps them to the same toasts it showed before via an exhaustive switch, so no message text changes. `AUTH_TYPES_REQUIRING_CREDENTIALS` and the static-header reducer were duplicated between the create and edit paths; the extracted module imports the create module's copies instead. The credential filter and stdio parser stay separate, because the edit versions genuinely differ: edit writes an explicit null to clear a blanked admin-config key, and stringifies stdio args and env values where create passes them through Behaviour is unchanged, and the payload net added earlier is what proves it: all 20 of its cases still pass against the extracted builder without any edit to their expectations. 40 unit tests cover the new module in single-digit milliseconds, reaching the rejection paths and parsing branches that were previously only reachable through a full render. A ten-mutant battery kills 10/10, each mutant taking down exactly one test, which is the profile worth having: the tests are targeted rather than broadly overlapping One of those mutants is worth noting. Removing the access-group name normalisation survives the integration net but dies here, because the antd Select hands the form plain strings and the unit test does not. That mapping is dead only while that control stays; it is covered now either way |
||
|---|---|---|
| .. | ||
| litellm-dashboard | ||
| Dockerfile | ||
| nginx.conf | ||