Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

fix: hide IntegrationPackage.ID from JSON #1211

Merged
merged 3 commits into from
Jun 1, 2021

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented May 29, 2021

What does this PR do?

It uses JSON tags to hide the field from JSON marshall/unmarshall operations.

Why is it important?

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema.

We are receiving a payload when getting integrations from Kibana, and that payload contains the ID, that's why we added the field to the struct. When sending POST requests to kibana to add an integration package to a policy, this struct is converted to JSON and sent as payload. But Kibana spec does not allow the ID field in its schema, and after elastic/kibana#99886 Kibana is stricter than before, as it fails with a HTTP 400 error code:

Error: could not add package to policy; API status code = 400; response body = {"statusCode":400,"error":"Bad Request","message":"[request body.package.id]: definition for this key is missing"}

In the past, before that Kibana PR, it simply ignored the field, which makes me think about a third party dependency in Kibana adding the new strictness.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have run the Unit tests (make unit-test), and they are passing locally
  • I have run the End-2-End tests for the suite I'm working on, and they are passing locally
  • I have noticed new Go dependencies (run make notice in the proper directory)

Author's Checklist

  • @kpollich I'm sending this workaround here too trying to simplify the fix in Kibana

How to test this PR locally

$ TAGS="linux_integration" TIMEOUT_FACTOR=3 LOG_LEVEL=TRACE BEATS_USE_CI_SNAPSHOT=false DEVELOPER_MODE=true make -C e2e/_suites/fleet functional-test

Related issues

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema
@mdelapenya mdelapenya self-assigned this May 29, 2021
@mdelapenya mdelapenya requested a review from a team May 29, 2021 07:14
@mdelapenya mdelapenya marked this pull request as ready for review May 29, 2021 07:15
@elasticmachine
Copy link
Contributor

elasticmachine commented May 29, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1211 updated

  • Start Time: 2021-06-01T04:59:15.079+0000

  • Duration: 21 min 5 sec

  • Commit: aa7b3d4

Test stats 🧪

Test Results
Failed 0
Passed 160
Skipped 0
Total 160

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 160
Skipped 0
Total 160

@mdelapenya mdelapenya merged commit 9430a9a into elastic:master Jun 1, 2021
mergify bot pushed a commit that referenced this pull request Jun 1, 2021
* fix: hide IntegrationPackage.ID from JSON

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema

* fix: run tests when changing internal

(cherry picked from commit 9430a9a)
mergify bot pushed a commit that referenced this pull request Jun 1, 2021
* fix: hide IntegrationPackage.ID from JSON

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema

* fix: run tests when changing internal

(cherry picked from commit 9430a9a)
mdelapenya added a commit that referenced this pull request Jun 1, 2021
* fix: hide IntegrationPackage.ID from JSON

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema

* fix: run tests when changing internal

(cherry picked from commit 9430a9a)

Co-authored-by: Manuel de la Peña <[email protected]>
mdelapenya added a commit that referenced this pull request Jun 1, 2021
* fix: hide IntegrationPackage.ID from JSON

This way, the requests to Kibana won't contain that field, honouring Kibana's contract about fleet schema

* fix: run tests when changing internal

(cherry picked from commit 9430a9a)

Co-authored-by: Manuel de la Peña <[email protected]>
@mdelapenya mdelapenya deleted the hide-integrations-ids branch June 1, 2021 12:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants