Skip to content

Add deepcopy #1

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

Open
wants to merge 1 commit into
base: future-master
Choose a base branch
from

Conversation

jonathan-buttner
Copy link

There is an issue with reusable fields getting clobbered that I ran into while creating the subset for the event schema. Adding a deepcopy avoids the issue.

The reason I'm PRing this here is so we can have one main branch to point people too until this gets merged into ecs core. I can also open a PR to ecs core. Not sure if this branch is eventually going in there.

@marshallmain
Copy link
Owner

I was using this branch just to collect the different PRs that I want to get into master in one place so this should be PR'd to master instead. Can you expand on how to reproduce the bug this PR fixes?

@marshallmain
Copy link
Owner

While looking back at other PRs I remembered what the issue is here. The tradeoff is between being able to subset the reused fields at the top level and having those restrictions apply to all the places where the reusable field is used - which is what I went for - and being able to subset the reusable field individually in each place where it is used.

I think you're right that we want to be able to subset reusable fields in each place where they're used independently. I have a PR up elastic#753 that moves the subset operation to after the reusables are inserted by reference but before they're deep copied to make each instance independent, which leads to the reusable clobbering. I'll update the PR to move the subset operation to after they're deep copied, this way we won't have to do multiple deep copies and this should fix the bug you're seeing.

@jonathan-buttner
Copy link
Author

jonathan-buttner commented Mar 26, 2020

I can't seem to reproduce this anymore haha. I'm pretty sure I was getting a crash and it was failing to find one of the fields that should have been there. I believe what was happening is this line was getting a reference to the fields part of the ecs core schema (https://github.com/marshallmain/ecs/blob/future-master/scripts/generators/ecs_helpers.py#L61) then when we recurse in the next line it would overwrite the original dict to only be the subset. Then when a different subset file required a field that the first subset didn't have it would fail.

Something like this

pe: {
  blah: 1,
  other: 2
}

subset1: {
  pe: {
    blah: *
  }
}

subset2: {
  pe: {
    other: * <-- that field wouldn't exist anymore
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants