Skip to content

fix(sdk): AttributeValueExists returns false instead of error for non-existent values#3195

Merged
marythought merged 1 commit intomainfrom
fix/sdk-attribute-value-exists-not-found
Mar 23, 2026
Merged

fix(sdk): AttributeValueExists returns false instead of error for non-existent values#3195
marythought merged 1 commit intomainfrom
fix/sdk-attribute-value-exists-not-found

Conversation

@marythought
Copy link
Copy Markdown
Contributor

@marythought marythought commented Mar 20, 2026

Summary

  • AttributeValueExists now catches CodeNotFound errors from GetAttributeValuesByFqns and returns (false, nil) instead of propagating the error
  • This matches the documented behavior and the pattern already used by AttributeExists (which already handles CodeNotFound correctly)
  • Adds a new test TestAttributeValueExists_NotFoundError covering this case

Test plan

  • go test -run TestAttributeValueExists -v — all 6 tests pass
  • golangci-lint run ./... — no new issues
  • CI checks pass

Fixes #3191

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in attribute value discovery. The SDK now gracefully handles missing attributes by returning a "not found" status instead of raising errors, enabling more reliable operations and smoother application behavior.
  • Tests

    • Added test coverage for missing attribute value scenarios in discovery operations.

…-existent values

GetAttributeValuesByFqns returns a CodeNotFound error when the FQN
does not exist. AttributeValueExists now catches this and returns
(false, nil), matching the documented behavior and the pattern
already used by AttributeExists.

Fixes #3191

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@marythought marythought requested review from a team as code owners March 20, 2026 23:03
@github-actions github-actions bot added the comp:sdk A software development kit, including library, for client applications and inter-service communicati label Mar 20, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses a bug in the SDK's AttributeValueExists function where it incorrectly returned an error when an attribute value did not exist, instead of the expected (false, nil). By catching CodeNotFound errors, the function now adheres to its documented behavior and maintains consistency with other attribute existence checks, enhancing the robustness and predictability of the SDK.

Highlights

  • Error Handling: The AttributeValueExists function was updated to correctly handle connect.CodeNotFound errors, returning (false, nil) instead of propagating the error.
  • Behavior Alignment: This change aligns the behavior of AttributeValueExists with its documented specification and the existing AttributeExists function, which already handles CodeNotFound errors appropriately.
  • Test Coverage: A new test, TestAttributeValueExists_NotFoundError, was added to specifically cover the scenario where GetAttributeValuesByFqns returns a CodeNotFound error.

🧠 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.

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.


Value not found, No error, just a false reply, Code now works right.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dfef325f-da71-4cd0-a9ad-49eb5d69768f

📥 Commits

Reviewing files that changed from the base of the PR and between 0057ff1 and 3c6508d.

📒 Files selected for processing (2)
  • sdk/discovery.go
  • sdk/discovery_test.go

📝 Walkthrough

Walkthrough

The AttributeValueExists method in the SDK discovery module now treats connect.CodeNotFound errors from GetAttributeValuesByFqns as a non-error case, returning (false, nil) instead of wrapping the error. A corresponding test verifies this behavior.

Changes

Cohort / File(s) Summary
Error Handling Fix
sdk/discovery.go, sdk/discovery_test.go
Modified AttributeValueExists to return (false, nil) when the underlying API call returns a CodeNotFound error, rather than wrapping it as an error. All other error codes continue to return errors as before. Added test TestAttributeValueExists_NotFoundError to verify this behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A method once broken, now healed with care,
Returns false, not errors, when values aren't there!
No workarounds needed, the fix flows so clean,
The simplest solution the SDK's ever seen! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main code change: treating CodeNotFound errors as a non-error case by returning false instead of error.
Linked Issues check ✅ Passed The PR changes directly implement the expected behavior from issue #3191: AttributeValueExists now returns (false, nil) instead of error for non-existent values, matching documented behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objectives: modifying AttributeValueExists error handling and adding a test for the not-found case.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sdk-attribute-value-exists-not-found

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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

This pull request addresses an issue where AttributeValueExists would propagate a CodeNotFound error instead of returning (false, nil). The change correctly handles this error case, aligning the function's behavior with its documentation and making it consistent with the AttributeExists function. A new test case, TestAttributeValueExists_NotFoundError, has been added to cover this scenario. The changes are correct and well-tested.

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 193.925997ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 101.837894ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 380.783376ms
Throughput 262.62 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.38952191s
Average Latency 392.674062ms
Throughput 126.94 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

@marythought marythought enabled auto-merge March 20, 2026 23:28
@marythought marythought added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 4e46091 Mar 23, 2026
41 checks passed
@marythought marythought deleted the fix/sdk-attribute-value-exists-not-found branch March 23, 2026 13:35
github-merge-queue bot pushed a commit that referenced this pull request Mar 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.15.0](sdk/v0.14.0...sdk/v0.15.0)
(2026-03-23)


### Bug Fixes

* **deps:** bump github.com/opentdf/platform/protocol/go from 0.16.0 to
0.20.0 in /sdk
([#3179](#3179))
([30bb0a8](30bb0a8))
* **sdk:** AttributeValueExists returns false instead of error for
non-existent values
([#3195](#3195))
([4e46091](4e46091))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:sdk A software development kit, including library, for client applications and inter-service communicati size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK AttributeValueExists returns error instead of false for non-existent values

2 participants