Skip to content

feat(sdk): DSPX-2418 add discovery convenience methods#339

Open
marythought wants to merge 3 commits intomainfrom
feat/dspx-2418-discovery-methods
Open

feat(sdk): DSPX-2418 add discovery convenience methods#339
marythought wants to merge 3 commits intomainfrom
feat/dspx-2418-discovery-methods

Conversation

@marythought
Copy link
Contributor

@marythought marythought commented Feb 17, 2026

Summary

  • Add five discovery methods directly on the SDK class: listAttributes(),
    validateAttributes(), validateAttributeExists(), validateAttributeValue(),
    getEntityAttributes()
  • Add SDK.AttributeNotFoundException extends SDKException, thrown when FQNs or attribute
    values are not found on the platform
  • Add 26 unit tests in DiscoveryTest.java covering all methods and edge cases
  • docs update: Feat: DSPX-2418 add SDK convenience/discovery method documentation docs#186

Rationale

Addresses GitHub discussion developer feedback. Developers currently work with verbose Connect RPC
request/response types through sdk.getServices().attributes(). These methods provide ergonomic
wrappers that:

  • Auto-paginate listAttributes() with a 1,000-page safety cap to prevent unbounded memory
    growth from a misbehaving server
  • Validate FQN format and existence before createTDF() so failures happen at encryption time
    with a clear message rather than at decryption time with a cryptic "resource not found"
  • Distinguish enumerated from dynamic attributes in validateAttributeValue(): enforces the
    registered value list (case-insensitively) for enumerated attributes; accepts any non-empty
    value for dynamic attributes
  • Match entity ID in the GetEntitlements response to prevent silent wrong-entity attribute
    returns
  • Cap validateAttributes() at 250 FQNs client-side to match the server limit

Matches the API shape and security properties of the Go SDK implementation: opentdf/platform#3082.

Test plan

  • mvn -pl sdk test -Dtest=DiscoveryTest — all 26 tests pass
  • mvn -pl sdk test — no regressions in existing test suite

@marythought marythought requested review from a team as code owners February 17, 2026 21:59
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @marythought, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the SDK by introducing ergonomic wrapper methods for attribute discovery and validation. These additions streamline developer interaction with the platform's attribute services, providing features like auto-pagination for attribute listings, early validation of FQNs to prevent cryptic decryption failures, and accurate retrieval of entity attributes. The changes aim to improve developer experience and system robustness by aligning the Java SDK with the API shape and security properties established in the Go SDK.

Highlights

  • New Convenience Methods: Four new discovery methods were added directly to the SDK class: listAttributes(), validateAttributes(), getEntityAttributes(), and validateAttributeValue().
  • New Exception Type: A new exception, SDK.AttributeNotFoundException, was introduced to be thrown when Fully Qualified Names (FQNs) are not found on the platform.
  • Comprehensive Unit Tests: Seventeen new unit tests were added in DiscoveryTest.java to cover all the new discovery methods and their various edge cases.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • sdk/src/main/java/io/opentdf/platform/sdk/SDK.java
    • Imported necessary classes for ConnectRPC, authorization, policy, and Java utility collections.
    • Introduced MAX_LIST_ATTRIBUTES_PAGES and MAX_VALIDATE_FQNS constants to control pagination and FQN validation limits.
    • Implemented listAttributes method to fetch all active attributes with auto-pagination and optional namespace filtering.
    • Implemented validateAttributes method to check FQN format and existence on the platform, including client-side limit enforcement.
    • Implemented getEntityAttributes method to retrieve attribute value FQNs assigned to a given entity.
    • Implemented validateAttributeValue as a convenience wrapper for single-FQN validation.
    • Defined AttributeNotFoundException as a static nested class within SDKException for specific attribute-related errors.
  • sdk/src/test/java/io/opentdf/platform/sdk/DiscoveryTest.java
    • Added a new test file, DiscoveryTest.java, to provide comprehensive unit test coverage for the new discovery methods.
    • Included helper methods for setting up mock SDK services and constructing test responses.
    • Implemented unit tests for listAttributes covering scenarios such as empty results, single-page and multi-page responses, namespace filtering, and exceeding the page limit.
    • Implemented unit tests for validateAttributes covering null/empty input, all FQNs found, some FQNs missing, all FQNs missing, exceeding the FQN limit, and invalid FQN format.
    • Implemented unit tests for getEntityAttributes covering null entity input, successful retrieval, no entitlements found, and entity ID mismatch scenarios.
    • Implemented unit tests for validateAttributeValue covering valid/existing, valid/missing, and invalid format cases.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces convenience methods for attribute discovery and validation within the SDK, along with a new AttributeNotFoundException. The changes are well-tested with comprehensive unit tests covering various scenarios and edge cases. The rationale for these changes, including auto-pagination and client-side validation, is clearly articulated and aligns with improving developer experience and system robustness. The new methods enhance the SDK's usability by abstracting verbose RPC calls, making it easier to interact with the platform's attribute services.

@github-actions
Copy link

X-Test Failure Report

Move MAX_LIST_ATTRIBUTES_PAGES and MAX_VALIDATE_FQNS to the top of the
class body (before instance fields), matching standard Java placement
for private static final constants.

Rename the lambda parameter in the validateAttributes stream filter from
'fqn' to 'f' to avoid the same name being used for both the enhanced-for
loop variable and the lambda parameter in the same method.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@github-actions
Copy link

X-Test Failure Report

The blocking service client methods do not declare `throws ConnectException`
in their Java signatures, so catching it is a compilation error. Remove the
three try-catch wrappers in listAttributes, validateAttributes, and
getEntityAttributes, letting exceptions propagate naturally — consistent with
the existing pattern in Autoconfigure.java.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@sonarqubecloud
Copy link

@github-actions
Copy link

Copy link
Contributor

@mkleene mkleene left a comment

Choose a reason for hiding this comment

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

Looks good!

The pagination API is a bit odd to me in that you have data that is both so large you need to paginate it and is of a size where we throw it all into a list but if that really comes up we can deal with it then. I guess that's probably just due to the fact that we paginated everything on the backend.

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

Comments