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

Add proper method to access scope root object #85

Merged
merged 5 commits into from
Apr 19, 2024

Conversation

jaredoconnell
Copy link
Contributor

@jaredoconnell jaredoconnell commented Apr 18, 2024

Changes introduced with this PR

This method adds validation for accessing the scope's root, and can be used outside of the SDK. It validates three possible mistakes.
There are three potential places to use this in the engine that I will need to address later.


By contributing to this repository, I agree to the contribution guidelines.

Copy link

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validations are a nice improvement over the direct dereference; although it "probably" gets called in other test cases where failure would be detected, an explicit "pass" test case would be nice.

schema/scope_test.go Show resolved Hide resolved
Copy link
Contributor

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good, but I don't think we should be panicking as a result of bad user input...and I have a couple of other comments.

schema/scope.go Outdated Show resolved Hide resolved
schema/scope.go Outdated Show resolved Hide resolved
schema/scope.go Outdated Show resolved Hide resolved
Copy link
Member

@mfleader mfleader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case_mismatched_root:
  root: wrong
  objects:
    a:
      id: a

case_mismatched_root_id:
  root: a
  objects:
    a:
      id: wrong

case3:
  root: a
  objects:
    wrong:
      id: a

The first two cases are what I believe your unit tests are addressing. Is case3 more so an issue with Object construction than Scope construction?

schema/scope_test.go Outdated Show resolved Hide resolved
schema/scope_test.go Outdated Show resolved Hide resolved
@jaredoconnell
Copy link
Contributor Author

case_mismatched_root:
  root: wrong
  objects:
    a:
      id: a

case_mismatched_root_id:
  root: a
  objects:
    a:
      id: wrong

case3:
  root: a
  objects:
    wrong:
      id: a

The first two cases are what I believe your unit tests are addressing. Is case3 more so an issue with Object construction than Scope construction?

The last one is also a scope problem, because "wrong" is a key in the scope map. It doesn't match the object ID of "a".

webbnh

This comment was marked as resolved.

webbnh

This comment was marked as resolved.

Copy link
Contributor Author

@jaredoconnell jaredoconnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had written this earlier, but couldn't post it because of a Github error.

schema/scope_test.go Show resolved Hide resolved
@jaredoconnell jaredoconnell merged commit 2e5a455 into main Apr 19, 2024
3 checks passed
@jaredoconnell jaredoconnell deleted the mismatched-root-segfault-fix branch April 19, 2024 19:22
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.

4 participants