Skip to content

Commit

Permalink
fixed compiled_input
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Dec 3, 2021
1 parent bdb5b79 commit b939ef3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ describe('When calling package policy', () => {
inputs: [
{
...existingPolicy.inputs[0],
compiled_input: '',
streams: [
{
...existingPolicy.inputs[0].streams[0],
Expand Down
24 changes: 14 additions & 10 deletions x-pack/plugins/fleet/server/routes/package_policy/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ export const updatePackagePolicyHandler: RequestHandler<
}

const body = { ...request.body };
// removed compiled_stream as not recognized by schema
const packagePolicyInputs = packagePolicy.inputs.map((input) => ({
...input,
streams: input.streams.map((stream) => {
const newStream = { ...stream };
delete newStream.compiled_stream;
return newStream;
}),
}));
// listing down accepted properties, because loaded packagePolicy contains some that are not accepted in update e.g. inputs.compiled_input
// removed fields not recognized by schema
const packagePolicyInputs = packagePolicy.inputs.map((input) => {
const newInput = {
...input,
streams: input.streams.map((stream) => {
const newStream = { ...stream };
delete newStream.compiled_stream;
return newStream;
}),
};
delete newInput.compiled_input;
return newInput;
});
// listing down accepted properties, because loaded packagePolicy contains some that are not accepted in update
let newData = {
...body,
name: body.name ?? packagePolicy.name,
Expand Down

0 comments on commit b939ef3

Please sign in to comment.