Skip to content

Conversation

@b-long
Copy link
Owner

@b-long b-long commented Aug 16, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@b-long
Copy link
Owner Author

b-long commented Aug 16, 2025

/gemini review

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

This pull request introduces a number of cleanups and improvements, such as removing deprecated code, improving type hints, and refactoring the KAS class out of the SDK class for better separation of concerns. The changes are generally good, but I've found a few issues, mostly in the new test files. There's a leftover debug print statement, a bug in the SDK builder logic for tests, and a call to a non-existent method in a new integration test. I've also suggested a small refactoring to reduce code duplication in a test helper file. Please review the comments for details.

Comment on lines +59 to +65
sdk = (
SDKBuilder()
.set_platform_endpoint(CONFIG_TDF.OPENTDF_PLATFORM_URL)
.set_issuer_endpoint(CONFIG_TDF.OPENTDF_KEYCLOAK_HOST)
.use_insecure_skip_verify(CONFIG_TDF.INSECURE_SKIP_VERIFY)
.build()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

It looks like the auth_token is not being passed to the SDKBuilder in the https branch of this conditional. This is inconsistent with the http branch and will likely cause authentication issues. The SDKBuilder should be initialized with auth_token=user_token here as well.

Suggested change
sdk = (
SDKBuilder()
.set_platform_endpoint(CONFIG_TDF.OPENTDF_PLATFORM_URL)
.set_issuer_endpoint(CONFIG_TDF.OPENTDF_KEYCLOAK_HOST)
.use_insecure_skip_verify(CONFIG_TDF.INSECURE_SKIP_VERIFY)
.build()
)
sdk = (
SDKBuilder(auth_token=user_token)
.set_platform_endpoint(CONFIG_TDF.OPENTDF_PLATFORM_URL)
.set_issuer_endpoint(CONFIG_TDF.OPENTDF_KEYCLOAK_HOST)
.use_insecure_skip_verify(CONFIG_TDF.INSECURE_SKIP_VERIFY)
.build()
)

Comment on lines +29 to +30
# tdf_reader = sdk.load_tdf(infile.read(), reader_config)
tdf_reader = sdk.load_tdf_without_config(infile.read())
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The method load_tdf_without_config does not exist on the SDK object. The correct method is sdk.load_tdf, which requires a TDFReaderConfig instance. Although this test is skipped, it's best to fix this to avoid confusion and make it easier to enable the test later.

Suggested change
# tdf_reader = sdk.load_tdf(infile.read(), reader_config)
tdf_reader = sdk.load_tdf_without_config(infile.read())
reader_config = TDFReaderConfig(attributes=_test_attributes)
tdf_reader = sdk.load_tdf(infile.read(), reader_config)

Returns:
Unwrapped key as bytes
"""
print("Pause")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This print() statement appears to be a leftover from debugging. It should be removed before merging.

Comment on lines +7 to +39
def get_sdk() -> SDK:
if CONFIG_TDF.OPENTDF_PLATFORM_URL.startswith("http://"):
sdk = (
SDKBuilder()
.set_platform_endpoint(CONFIG_TDF.OPENTDF_PLATFORM_URL)
.set_issuer_endpoint(CONFIG_TDF.OPENTDF_KEYCLOAK_HOST)
.client_secret(
CONFIG_TDF.OPENTDF_CLIENT_ID,
CONFIG_TDF.OPENTDF_CLIENT_SECRET,
)
.use_insecure_plaintext_connection(True)
.use_insecure_skip_verify(CONFIG_TDF.INSECURE_SKIP_VERIFY)
.build()
)
elif CONFIG_TDF.OPENTDF_PLATFORM_URL.startswith("https://"):
sdk = (
SDKBuilder()
.set_platform_endpoint(CONFIG_TDF.OPENTDF_PLATFORM_URL)
.set_issuer_endpoint(CONFIG_TDF.OPENTDF_KEYCLOAK_HOST)
.client_secret(
CONFIG_TDF.OPENTDF_CLIENT_ID,
CONFIG_TDF.OPENTDF_CLIENT_SECRET,
)
.use_insecure_skip_verify(CONFIG_TDF.INSECURE_SKIP_VERIFY)
.build()
)
else:
raise ValueError(
f"Invalid platform URL: {CONFIG_TDF.OPENTDF_PLATFORM_URL}. "
"It must start with 'http://' or 'https://'."
)

return sdk
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's some code duplication in get_sdk between the http:// and https:// branches. This could be refactored to make the code more concise and maintainable. You could create the SDKBuilder instance with all common calls, and then conditionally call use_insecure_plaintext_connection(True) if the URL starts with http://.

@b-long b-long closed this Aug 16, 2025
@b-long b-long deleted the chore/pe-workflow-support-and-cleanup branch August 16, 2025 16:07
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