Skip to content

Conversation

agrawalreetika
Copy link
Member

Description

Fix Ranger plugin deserialisation to ignore unknown fields.

The Hive Ranger plugin was failing to fetch policies from Ranger servers with versions newer than 2.1.0. The failure was due to Jackson throwing -

UnrecognizedPropertyException for fields like category
in RangerServiceDef$RangerAccessTypeDef.

This change configures the ObjectMapper to ignore unknown properties during deserialization, allowing the plugin to work with newer Ranger servers without failing.

Motivation and Context

Support current client features even with upgraded Ranger instance version > 2.1.0

Impact

Test Plan

Modified the test policy file to include an extra field, which would cause deserialization to fail. Updated ObjectMapper to ignore unknown properties to prevent exceptions.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@agrawalreetika agrawalreetika requested a review from a team as a code owner October 15, 2025 12:38
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Oct 15, 2025
@prestodb-ci prestodb-ci requested review from a team, ShahimSharafudeen and sh-shamsan and removed request for a team October 15, 2025 12:38
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Ranger plugin to configure Jackson’s ObjectMapper to ignore unknown fields during deserialization, enhances exception handling to include the root cause, and adjusts test fixtures to validate the new behavior, ensuring compatibility with newer Ranger server versions.

Sequence diagram for improved policy fetch error handling

sequenceDiagram
    participant RangerBasedAccessControl
    participant HttpClient
    participant RangerServer
    participant ExceptionHandler
    RangerBasedAccessControl->>HttpClient: execute(request)
    HttpClient->>RangerServer: Fetch policies
    RangerServer-->>HttpClient: Response (may contain unknown fields)
    HttpClient-->>RangerBasedAccessControl: Response body
    RangerBasedAccessControl->>ObjectMapper: readValue(response, ServicePolicies.class)
    ObjectMapper-->>RangerBasedAccessControl: ServicePolicies or Exception
    alt Exception thrown
        RangerBasedAccessControl->>ExceptionHandler: throw PrestoException with root cause
    end
Loading

Class diagram for updated RangerBasedAccessControl deserialization

classDiagram
    class RangerBasedAccessControl {
        - static ObjectMapper OBJECT_MAPPER
        + static ObjectMapper OBJECT_MAPPER (configured to ignore unknown properties)
        - static JsonCodec USER_INFO_CODEC
        - static JsonCodec ROLES_INFO_CODEC
        ...
        + ServicePolicies getHiveServicePolicies(RangerBasedAccessControlConfig config)
    }
    class ObjectMapper {
        + configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
    }
    RangerBasedAccessControl --> ObjectMapper
Loading

File-Level Changes

Change Details Files
Configure ObjectMapper to ignore unknown properties during deserialization
  • Chain configure call on OBJECT_MAPPER to disable FAIL_ON_UNKNOWN_PROPERTIES
presto-hive/src/main/java/com/facebook/presto/hive/security/ranger/RangerBasedAccessControl.java
Improve error handling in getHiveServicePolicies
  • Include the caught IOException as the cause when throwing PrestoException
presto-hive/src/main/java/com/facebook/presto/hive/security/ranger/RangerBasedAccessControl.java
Update test JSON to include an extra unknown field
  • Add an extra field to the default-allow-all.json fixture to simulate unknown properties
presto-hive/src/test/resources/com.facebook.presto.hive.security.ranger/default-allow-all.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@prestodb-ci
Copy link
Contributor

@agrawalreetika imported this issue as lakehouse/presto #26315

@tdcmeehan tdcmeehan self-assigned this Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants