Skip to content

Enable python client debug flag#2154

Merged
MonkeyCanCode merged 2 commits intoapache:mainfrom
MonkeyCanCode:python_client_debug_flag
Jul 31, 2025
Merged

Enable python client debug flag#2154
MonkeyCanCode merged 2 commits intoapache:mainfrom
MonkeyCanCode:python_client_debug_flag

Conversation

@MonkeyCanCode
Copy link
Contributor

Enable request tracing via money patching:

Original:

➜  polaris git:(python_client_debug_flag) ./polaris --profile dev principals list
{"name": "root", "clientId": "root", "properties": {}, "createTimestamp": 1753151091780, "lastUpdateTimestamp": 1753151091780, "entityVersion": 1}

With debug mode (dummy password from the getting start example):

➜  polaris git:(python_client_debug_flag) ./polaris --profile dev --debug principals list
Request: POST http://localhost:8181/api/catalog/v1/oauth/tokens
Headers: HTTPHeaderDict({'Content-Type': 'application/x-www-form-urlencoded'})
Body: grant_type=client_credentials&client_id=root&client_secret=s3cr3t&scope=PRINCIPAL_ROLE%3AALL

Request: GET http://localhost:8181/api/management/v1/principals
Headers: {'Accept': 'application/json', 'User-Agent': 'OpenAPI-Generator/1.0.0/python', 'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwb2xhcmlzIiwic3ViIjoiMSIsImlhdCI6MTc1MzE1NjUwMiwiZXhwIjoxNzUzMTYwMTAyLCJqdGkiOiIyMjc3NTc4Yi1mOGQ2LTQ3NjctODc2Yy0xZjg0YjVhOTFjOWIiLCJhY3RpdmUiOnRydWUsImNsaWVudF9pZCI6InJvb3QiLCJwcmluY2lwYWxJZCI6MSwic2NvcGUiOiJQUklOQ0lQQUxfUk9MRTpBTEwifQ.CXHMjqgGtGZZ9hUtS_Tqi4hr2Zt5kIdifqWVH0sWO2Ycbju3J6f4KWu4TgBB7FT6PQUbFqIAZiNBOAkZRpCDygUPEZ3-bt3cbTt9LWfkQYRXFnJF7-fM42zSK3Go7t1AVfYShDLozexgBvZGg700SYdcffKdCpARke7IX8VjLl_0uqZ4ygtjWwmoIHxfVH8WCTXajdvTOH7MF6aPgdVr5_y4KiCfZoTu5DG9gSJLYYAu1sVfUtQ07hGWs6wJUENLt9ZBjBBJI80Um70Oq3U508MC4y10FBWIKRrs8655le976TfcRjY_BPxpJaekBQIrxP7qz1hqP8XGSPRuFTgWbQ'}

{"name": "root", "clientId": "root", "properties": {}, "createTimestamp": 1753151091780, "lastUpdateTimestamp": 1753151091780, "entityVersion": 1}

Also, as the current code will requires an user to provide an argument even if the type is bool. To fix that (assuming that is not intensional), a code fix is provided (otherwise, we will need to do --debug XXX.

sys.stderr.write(f"Headers: {kwargs['headers']}\n")
if "body" in kwargs:
sys.stderr.write(f"Body: {kwargs['body']}\n")
sys.stderr.write("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: looks like this newline is not needed

# Define the wrapper function
@functools.wraps(urllib3.PoolManager.original_urlopen)
def urlopen_wrapper(self, method, url, **kwargs):
sys.stderr.write(f"Request: {method} {url}\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if there's a standard format for this kind of thing -- what you have looks good to me though. If we were taking the dry-run approach, it might be nice to print a runnable command like a curl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I can do that in the next PR.

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jul 30, 2025
@MonkeyCanCode MonkeyCanCode merged commit 0531b21 into apache:main Jul 31, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Jul 31, 2025
snazy added a commit to snazy/polaris that referenced this pull request Nov 20, 2025
* Simplify BaseMetaStoreManager.extractStorageConfiguration (apache#2194)

as a static helper method its strongly preferable to not depend on
the full `PolarisCallContext` if not necessary.

* Remove PolarisCallContext from TreeMapMetaStore (apache#2195)

* remove PolarisCallContext from TreeMapMetaStore methods

* reset diagnosticServices in TreeMapMetaStore

* simplify ensure methods

* Remove getCurrentContext from InMemoryStorageIntegration (apache#2201)

* Remove getCurrentContext from JWTBroker (apache#2202)

* fix(deps): update dependency boto3 to v1.39.17 (apache#2211)

* fix(deps): update dependency org.apache.commons:commons-compress to v1.28.0 (apache#2212)

* Enable python client debug flag (apache#2154)

* Enable python client debug flag

* Move debug msg to stderr and move debug enable after option parsing

* Remove postgres_latest as image tag (apache#2045)

* Remove postgres_latest as image tag

* Change image tag to latest for getting started examples

* Change image tag to latest from helm

* fix(deps): update dependency io.smallrye.common:smallrye-common-annotation to v2.13.8 (apache#2222)

* Remove CallContextResolver (apache#2215)

it seems like these were unused leftovers from previous changes

* Replace CommitFailedException with CommitConflictException (apache#2198)

* Replace CommitFailedException with CommitConflictException

In some cases, we were using CommitFailedException to represent commit
conflicts, which returns the correct 409 response but is tied to Iceberg.

However, some of these conflicts originate from Polaris, making
CommitConflictException a more appropriate and accurate choice.

This change updates those instances to improve clarity and exception
handling semantics.

Resolves apache#2168

* JDBC: Include error code + SQL state in exception messages (apache#2220)

* fix(deps): update dependency boto3 to v1.40.0 (apache#2225)

* chore(deps): update actions/stale digest to 8f717f0 (apache#2224)

* Fix Awaitility build configuration (apache#2232)

* Fix compilation warnings in AzureCredentialStorageIntegrationTest (apache#2231)

* Remove CallContext.CURRENT_CONTEXT (apache#2203)

the last callers of `CallContext.getCurrentContext` had been
removed in the following commits:

- 756e535
- e7eb59f
- 4d94745

thus we can now remove the `CURRENT_CONTEXT` threadlocal and all
associated methods.

* NoSQL: adoptions & cosmetics

* Last merged commit 0449d9b

---------

Co-authored-by: Christopher Lambert <[email protected]>
Co-authored-by: Mend Renovate <[email protected]>
Co-authored-by: Yong Zheng <[email protected]>
Co-authored-by: Tamas Mate <[email protected]>
Co-authored-by: Alexandre Dutra <[email protected]>
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