feat(sdk): DSPX-2418 add attribute discovery methods#3082
feat(sdk): DSPX-2418 add attribute discovery methods#3082marythought wants to merge 3 commits intomainfrom
Conversation
Summary of ChangesHello @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 Go SDK by providing a set of new methods for attribute discovery and validation. These additions aim to streamline the developer workflow by offering ergonomic ways to interact with attributes, ensuring their existence and proper assignment before critical operations like TDF creation. The changes improve the SDK's robustness and developer experience by preventing common pitfalls related to attribute management. Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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. Attributes now found, SDK guides the true path, Data flows secure. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces several useful attribute discovery methods to the Go SDK, which will improve the developer experience for discovering and validating attributes. The implementation is well-structured and includes comprehensive unit tests. I've identified one high-severity issue in GetEntityAttributes that could lead to incorrect data being returned, and a medium-severity suggestion to improve performance in ListAttributes.
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Prefer nil over []string{} as the zero value for a slice return
when no entitlements match the requested entity ID.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
- Pre-allocate the result slice in ListAttributes using PageResponse.Total on the first page, reducing allocations when paginating large lists. - Remove the entityID == "" short-circuit in GetEntityAttributes that caused the first entitlement in the response to be returned regardless of its entity ID when the caller passed an entity with no ID. - Add TestGetEntityAttributes_EmptyEntityID to cover the fixed case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Summary
Adds five convenience discovery methods to the Go SDK's SDK struct, addressing GitHub Discussions #947 and #1204 where developers had no ergonomic way to discover attributes or validate them before encryption.
Security hardening applied during implementation
ListAttributescapped at 1000 pages to prevent unbounded memory growth from a misbehaving serverValidateAttributesenforces the server's 250-FQN limit client-side for a clear local errorGetEntityAttributesmatches response entitlements against the requested entity ID rather than blindly returning index 0Checklist
Testing Instructions
sdk/discovery_test.gocovering all methods, edge cases (empty input, pagination overflow, ID mismatch, service errors, invalid FQN format)go test ./sdk/...passes (pre-existingauth/oauthfailure is unrelated)golangci-lint run ./sdk/...— no new issues introducedopentdf/docs