Files
Yonatan Beker 9412b4edf8 fix(integrations): parse real response shape in cx integrations list (#146)
## Summary

`cx integrations list` returned an empty result even when the account
had integrations and a direct API call returned them.

**Root cause:** the list handler deserialized the response into a struct
expecting a top-level `deployments[]` array of flat `{id, name, type,
status, version}` objects. The real
`/mgmt/openapi/5/integrations/integrations/v1` endpoint returns the list
under `integrations[]`, with each item nested one level deeper under an
`integration` key and a different shape:

```json
{ "integrations": [ { "integration": { "id", "name", "tags", "versions": ["0.0.40"], "integrationType": {"managed":{}} }, "errors": [] } ] }
```

Because the expected field was annotated `#[serde(default)]`, the total
shape mismatch deserialized to an **empty Vec with no error** — so the
command silently showed nothing while the API returned data. The struct
was originally written against assumed field names with a mock that
mirrored those assumptions, so tests passed without ever matching the
real API.

## Behavior change

- `cx integrations list` now returns the integrations the API actually
returns (verified end-to-end: 64 items in eu2 vs. previously empty).
- Output schema per row changed from `{id, name, type, status, version}`
to `{id, name, type, version, tags}`:
- `type` is derived from the `integrationType` oneof key
(`cloudformation` / `arm` / `managed` / `untracked`).
- `version` is the latest entry of the `versions[]` array (string,
previously a `u32`).
- `status` is dropped (not present in the API response); `tags` is
added.
- Text table columns are now: ID, Name, Type, Version, Tags.

## Notes

- `?onlyDeployed=true` is silently ignored by the backend (still returns
the full set), and `/integrations/v1` is the only listing endpoint — it
returns the integration definitions/catalog, which is what a direct API
call surfaces.
- The create/`SaveIntegrationResponse` (POST) shape was left untouched —
it could not be verified without creating a real integration. Worth
confirming separately if `cx integrations create` is in use.

## Test plan

- [x] `cargo build`, `cargo clippy`, `cargo fmt`
- [x] `cargo test integrations` (unit + wiremock) updated to the real
payload shape
- [x] Manual: `cx integrations list -o text` / `-o json` against eu2
returns 64 integrations

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-17 14:45:04 +03:00
..