Skip to content

CLI: non-JSON responses parsed as JSON under --json #588

Description

@JoshMock

Opened from failing KB functional tests in test/functional/kb/definitions/. Non-JSON responses are parsed as JSON under --json. Endpoints returning YAML (GET .../download) or NDJSON (export_list_items) trigger client-side parse errors (Unexpected non-whitespace character after JSON), so the test fails on an unparseable response.

Respect the response content-type (or the endpoint's declared x-response-type) and pass through text/NDJSON bodies instead of calling JSON.parse. Add a unit test with a text/yaml and an application/x-ndjson response asserting the raw body is returned and exit code is 0.

Failing test definitions:

  • elastic_agent_policies_get_fleet_kubernetes_download.yml (stack + serverless)
  • security_lists_api_export_list_items.yml (stack)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions