Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Differences between Output API spec and what is returned by the API #167181

Closed
taylor-swanson opened this issue Sep 25, 2023 · 2 comments · Fixed by #168938
Closed

[Fleet] Differences between Output API spec and what is returned by the API #167181

taylor-swanson opened this issue Sep 25, 2023 · 2 comments · Fixed by #168938
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@taylor-swanson
Copy link

While working on updating the terraform provider for fleet, I noticed that when moving to v8.10.0 of the OpenAPI spec (https://raw.githubusercontent.com/elastic/kibana/v8.10.0/x-pack/plugins/fleet/common/openapi/bundled.json), there's a mismatch between what the spec claims the schema should be, and what is actually returned by the API.

The 8.10.0 and later schema seems to remove embedding the output data in an item object, but the API still returns the pre-8.10.0 style, where the output object is embedded in an item object.

In the terraform provider project, we are using the following paths/methods:

  • GET /outputs/{outputId} (Affected)
  • PUT /outputs/{outputId} (Affected)
  • POST /outputs (Not affected)
  • DELETE /outputs/{outputId} (Not affected)

So from what I can tell, only the GET and PUT methods are affected by this.

Before 8.10.0:

"/outputs/{outputId}": {
      "get": {
        "summary": "Get output by ID",
        "tags": [
          "Outputs"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "item": {
                      "$ref": "#/components/schemas/output"
                    }
                  },
                  "required": [
                    "item"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/error"
          }
        },
        "operationId": "get-output"
      },

In 8.10.0 and later:

"/outputs/{outputId}": {
  "get": {
    "summary": "Get output by ID",
    "tags": [
      "Outputs"
    ],
    "responses": {
      "200": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/output_create_request"
            }
          }
        }
      },
      "400": {
        "$ref": "#/components/responses/error"
      }
    },
    "operationId": "get-output"
  }
}

I'm not sure if dropping the output type in favor of output_create_request was intentional, but when I at least account for the item issue, I can unmarshal responses seemingly okay, so I don't think that is a major issue.

Here's what's returned by the API on 8.10.2:

GET https://localhost:5601/api/fleet/outputs/fleet-default-output

{
    "item": {
        "id": "fleet-default-output",
        "name": "default",
        "type": "elasticsearch",
        "hosts": [
            "https://elasticsearch:9200"
        ],
        "ca_trusted_fingerprint": "F22AC4B76227ABA21D6CD2616D184FFF980106C4DBB5EEDBA84A7AE21797B47D",
        "is_default": true,
        "is_default_monitoring": true,
        "is_preconfigured": true,
        "config_yaml": null,
        "ca_sha256": null
    }
}
@taylor-swanson taylor-swanson added the Team:Fleet Team label for Observability Data Collection Fleet team label Sep 25, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic juliaElastic added the bug Fixes for quality problems that affect the customer experience label Sep 27, 2023
@juliaElastic
Copy link
Contributor

This change was introduced when adding kafka output, I think this is a mistake in openapi spec, the API itself hasn't changed (still having output wrapped in item).
So I think this is a bug we should fix cc @kpollich

@criamico criamico self-assigned this Oct 16, 2023
criamico added a commit that referenced this issue Oct 16, 2023
Fixes #167181

## Summary
Fix of Fleet openapi specs: `item` was mistakenly removed in the
responses of these two endpoints:
- GET /outputs/{outputId}
- PUT /outputs/{outputId}

Adding back the missing fields to align the actual behavior with the
docs.

### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
dej611 pushed a commit to dej611/kibana that referenced this issue Oct 17, 2023
Fixes elastic#167181

## Summary
Fix of Fleet openapi specs: `item` was mistakenly removed in the
responses of these two endpoints:
- GET /outputs/{outputId}
- PUT /outputs/{outputId}

Adding back the missing fields to align the actual behavior with the
docs.

### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants