Summary
The library models list endpoints (computers.list(), clients.list(), locations.list(), alerts.list(), scripts.list(), etc.) as returning { Data: T[]; TotalRecords?: number }, but the live ConnectWise Automate REST API returns a bare JSON array for these endpoints.
Because HttpClient.handleResponse does a blind return response.json() as Promise<T> (no runtime validation), the mismatch compiles cleanly and only surfaces at runtime. Any consumer that reads response.Data gets undefined and crashes (e.g. response.Data.length → Cannot read properties of undefined (reading 'length')).
This was hit downstream in connectwise-automate-mcp (issue #35), which now compensates by normalizing both shapes at its boundary. But every other SDK consumer re-inherits the same bug, so it should be fixed at the source.
Corroboration that list endpoints return a bare array: the widely-used connectwise-rest client types Automate /api/v1/Computers as Promise<Array<LabTechModelsComputer>>.
Suggested fix
- Correct the
*ListResponse types to reflect the real bare-array shape (or make the resource methods unwrap a { Data, TotalRecords } envelope into a typed array + total if some deployments/endpoints really do wrap — confirm against a live server).
- Replace the unchecked
response.json() as T cast in HttpClient with runtime-validated parsing (or at least a normalization layer for list endpoints) so a shape drift surfaces as a clear error rather than a downstream undefined crash.
PaginatedIterable (listAll()) reads response.Data and has the same assumption — fix it alongside.
Affects v1.0.2.
Summary
The library models list endpoints (
computers.list(),clients.list(),locations.list(),alerts.list(),scripts.list(), etc.) as returning{ Data: T[]; TotalRecords?: number }, but the live ConnectWise Automate REST API returns a bare JSON array for these endpoints.Because
HttpClient.handleResponsedoes a blindreturn response.json() as Promise<T>(no runtime validation), the mismatch compiles cleanly and only surfaces at runtime. Any consumer that readsresponse.Datagetsundefinedand crashes (e.g.response.Data.length→Cannot read properties of undefined (reading 'length')).This was hit downstream in
connectwise-automate-mcp(issue #35), which now compensates by normalizing both shapes at its boundary. But every other SDK consumer re-inherits the same bug, so it should be fixed at the source.Corroboration that list endpoints return a bare array: the widely-used
connectwise-restclient types Automate/api/v1/ComputersasPromise<Array<LabTechModelsComputer>>.Suggested fix
*ListResponsetypes to reflect the real bare-array shape (or make the resource methods unwrap a{ Data, TotalRecords }envelope into a typed array + total if some deployments/endpoints really do wrap — confirm against a live server).response.json() as Tcast inHttpClientwith runtime-validated parsing (or at least a normalization layer for list endpoints) so a shape drift surfaces as a clear error rather than a downstreamundefinedcrash.PaginatedIterable(listAll()) readsresponse.Dataand has the same assumption — fix it alongside.Affects v1.0.2.