Skip to content

fix(xtest): reclassify policy binding failures as KAS request errors#421

Merged
marythought merged 2 commits intomainfrom
fix/xtest-kas-error-reclassify
Mar 18, 2026
Merged

fix(xtest): reclassify policy binding failures as KAS request errors#421
marythought merged 2 commits intomainfrom
fix/xtest-kas-error-reclassify

Conversation

@marythought
Copy link
Copy Markdown
Contributor

Summary

  • Add assert_kas_request_error for policy binding failure tests (test_tdf_with_unbound_policy, test_tdf_with_altered_policy_binding)
  • These tests now correctly expect KAS request errors (400) rather than tamper/integrity errors
  • Backward compatible: accepts both new (KAS request error, rewrap request 400) and legacy (tamper, InvalidFileError) error strings
  • Remove unused "wrap" case from assert_tamper_error

Context

Companion to opentdf/platform#3166, which reclassifies ErrRewrapBadRequest away from ErrTampered and under a new ErrKASRequestError. Policy binding mismatches cause KAS to return 400 Bad Request — a request-level error, not a tamper/integrity issue.

Test plan

🤖 Generated with Claude Code

Policy binding mismatches (unbound policy, altered binding) cause KAS to
return a 400 Bad Request, which is a request-level error — not a
tamper/integrity issue detected by the SDK. Add assert_kas_request_error
for these cases, accepting both the new "KAS request error" classification
and legacy "tamper" strings for backward compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@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 refactors error handling in xtest for policy binding failures, aligning the test suite with recent platform changes that reclassify these issues as KAS request errors (HTTP 400) instead of tamper errors. It introduces a dedicated assertion helper for KAS request errors, ensuring tests accurately reflect the expected error type while maintaining backward compatibility for older SDK versions.

Highlights

  • New KAS Request Error Assertion: Introduced assert_kas_request_error to specifically handle policy binding failures, expecting KAS request errors (HTTP 400).
  • Updated Policy Binding Tests: Modified test_tdf_with_unbound_policy and test_tdf_with_altered_policy_binding to use the new assert_kas_request_error for more accurate error classification.
  • Backward Compatibility: The new assertion function includes checks for both the new KAS request error strings and legacy tamper/integrity error strings to maintain compatibility with older SDK versions.
  • Refactored Tamper Error Assertion: Removed the unused "wrap" case and its associated InvalidFileError from assert_tamper_error, streamlining the function.

🧠 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
  • xtest/test_tdfs.py
    • Removed the "wrap" case and InvalidFileError from assert_tamper_error.
    • Added a new function assert_kas_request_error to validate KAS request errors, including backward compatibility for legacy tamper errors.
    • Updated test_tdf_with_unbound_policy to use assert_kas_request_error.
    • Updated test_tdf_with_altered_policy_binding to use assert_kas_request_error.
Activity
  • The author plans to merge this PR first.
  • The author plans to verify opentdf/platform#3166 xtest jobs pass after this lands.
  • The pull request was generated with Claude Code.
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.

@marythought
Copy link
Copy Markdown
Contributor Author

Blocked by / companion to: opentdf/platform#3166

This PR should merge first so that the platform PR's xtest CI passes.

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 correctly refactors the error handling for policy binding failures in tests. A new assert_kas_request_error function is introduced to check for KAS request errors, which is more accurate than the previous classification as tamper errors. The changes are backward compatible by checking for both new and legacy error messages. The old logic for this case has been cleanly removed from assert_tamper_error. I've identified a minor improvement opportunity to simplify the signature of the new helper function.

Comment thread xtest/test_tdfs.py
Comment thread xtest/test_tdfs.py
Comment thread xtest/test_tdfs.py
@github-actions
Copy link
Copy Markdown

@marythought
Copy link
Copy Markdown
Contributor Author

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

@marythought marythought merged commit c03ee64 into main Mar 18, 2026
14 checks passed
@marythought marythought deleted the fix/xtest-kas-error-reclassify branch March 18, 2026 14:42
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