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

Union fix #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Union fix #8

wants to merge 6 commits into from

Commits on May 2, 2018

  1. Use rake for make tasks

    We already need `rake` to work with this gem, and it's capable of
    basically everything that `make` is; unify build tools to prevent
    confusion.
    
    Move the test thrift files into the test/ directory to avoid clutter,
    plus add a `clean` target for `rake` that wipes built definitions.
    
    Also, add minitest as a dependency, since it’s not built into newer
    Ruby versions.
    anujdas committed May 2, 2018
    Configuration menu
    Copy the full SHA
    c2b7a00 View commit details
    Browse the repository at this point in the history
  2. Fix union and collection validation edge cases

    Some things passed/returned to Thrift endpoints are not themselves
    Thrift objects, e.g., lists, primitives, or nil. These can and should
    still be validated. Since we're anyway not making use of type hints in
    the schema and relying on Thrift structs to self-validate, we can just
    recurse the struct tree and let what can be validated be validated,
    greatly cleaning up implementation while adding functionality.
    
    For example, union validation was broken for a very specific edge case:
    when a field that was a container around structs is not set, validation
    produces a highly confusing error message indicating that the unset
    field is, in fact, not set. Consider the Thrift definition
    
      union UnionExample {
        1: list<SomeStruct> primary,
        2: string alternate,
      }
    
    Setting the `alternate` field caused validation to fail, claiming that
    the `primary` field was not the set_field. This was due to the validator
    accessing the unset field, because the code meant to check this case
    only ran for specific field types. Now it performs correctly regardless
    of field type.
    anujdas committed May 2, 2018
    Configuration menu
    Copy the full SHA
    de46952 View commit details
    Browse the repository at this point in the history
  3. Fix inconsistency in union validation errors

    Union validation used to raise a StandardError, which doesn't make sense
    when the rest of the validation failures cause ProtocolExceptions.
    Make that uniform.
    anujdas committed May 2, 2018
    Configuration menu
    Copy the full SHA
    f12f9d0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6f7cd02 View commit details
    Browse the repository at this point in the history
  5. Bump gem version to 0.2.0

    The library's error changes and new functionality seem like enough to
    bump the minor version. In particular, union validation now raises a
    different error (ProtocolException) than it used to (StandardError).
    anujdas committed May 2, 2018
    Configuration menu
    Copy the full SHA
    ee60561 View commit details
    Browse the repository at this point in the history

Commits on May 4, 2018

  1. Fix usage in README

    Validator#validate is an instance method; reflect this in the docs.
    anujdas committed May 4, 2018
    Configuration menu
    Copy the full SHA
    4817332 View commit details
    Browse the repository at this point in the history