elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.69k stars 8.12k forks source link

[Fleet] API endpoint package_policies returns 500 on PUT with unknown ID #186486

Open Daantie opened 2 months ago

Daantie commented 2 months ago

Kibana version: 8.13.4 Elasticsearch version: 8.13.4 Server OS version: Elastic Cloud Browser version: N/A Browser OS version: N/A Original install method (e.g. download page, yum, from source, etc.): N/A

Describe the bug: The package_policies API returns 500 on a PUT request with unknown ID.

Steps to reproduce:

  1. Try to update an integration that doesn't exist:
    PUT kbn:/api/fleet/package_policies/noid
    {
    "id": "noid",
    "policy_id": "agentPolicyId",
    "package": {
    "name": "log",
    "version": "1.1.1"
    },
    "name": "thisisaname",
    "description": "",
    "namespace": "default",
    "inputs": {
    "logs-logfile": {
      "enabled": true,
      "streams": {
        "log.log": {
          "enabled": true,
          "vars": {
            "paths": [
              "test"
            ],
            "data_stream.dataset": "generic",
            "tags": [],
            "custom": ""
          }
        }
      }
    }
    }
    }
  2. Watch the request return a 500 server error:
    {
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "An internal server error occurred. Check Kibana server logs for details."
    }

Expected behavior: I expect the API to return a 404, just like the agent_policies endpoint:

{
    "statusCode": 404,
    "error": "Not Found",
    "message": "Saved object [ingest-agent-policies/noid] not found"
}

Provide logs and/or server output (if relevant): This is from the kibana logs. Seems like the same message that is returned with the agent_policies 404 response.

...
          "message": "500 Server Error",
          "error": {
            "message": "Saved object [ingest-package-policies/noid] not found"
          },
...
elasticmachine commented 2 months ago

Pinging @elastic/fleet (Team:Fleet)