Skip to content

Commit 9aab64d

Browse files
authored
Fix/get user info (#95)
* fix get user info * release: bump version to 0.4.11 (patch release) * add changelog * fix test
1 parent 185941d commit 9aab64d

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

changelog/0.4.11.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# [0.4.11] - 2025-08-22
1+
# [0.4.11] - 2025-09-01
22

3-
## Added
3+
## Fixed
44

5-
- `get_job` tool now supports fetching job details by job ID.
6-
- `run_sql` tool now supports optional username and password parameters for database authentication.
5+
- `get_user_info`tool retrieves the user details correctly.

changelog/0.4.12.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# [0.4.12] - 2025-09-22
2+
3+
## Added
4+
5+
- `get_job` tool now supports fetching job details by job ID.
6+
- `run_sql` tool now supports optional username and password parameters for database authentication.

src/api/common.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,22 +313,19 @@ def __get_workspace_endpoint(
313313

314314
def fetch_user() -> Dict[str, Any]:
315315
"""
316-
Get the current user's ID from the management API.
316+
Get the current user's information from the management API.
317317
318318
Returns:
319-
str: The user ID
319+
Dict[str, Any]: User information including userID, email, firstName, lastName
320320
"""
321321

322322
# Get all users in the organization
323-
users = build_request("GET", "users")
323+
user = build_request("GET", "users/current")
324324

325-
# Find the current user
326-
# Since we can't directly get the current user ID, we'll use the first user
327-
# In a real implementation, we might need additional logic to identify the current user
328-
if users and isinstance(users, list) and len(users) > 0:
329-
return users[0]
325+
if user is not None:
326+
return user
330327

331-
raise ValueError("Could not retrieve user ID from the API")
328+
raise ValueError("Could not retrieve user information from the API")
332329

333330

334331
def get_org_id() -> str | None:

src/api/tools/database/database.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ async def run_sql(
336336
"errorCode": "AUTHENTICATION_ERROR",
337337
}
338338

339+
logger.debug(
340+
f"Credentials obtained for workspace '{target.name}': username='{username}', database='{database_name}, password='{password}'"
341+
)
342+
339343
# Execute the SQL query
340344
start_time = time.time()
341345
try:

src/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.10"
1+
__version__ = "0.4.11"

tests/integration/tools/test_user.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ async def test_get_user_info(self, mock_context):
3535
assert user_data["email"] is not None
3636
assert user_data["firstName"] is not None
3737
assert user_data["lastName"] is not None
38+
39+
assert user_data["firstName"] == "Pedro"
40+
assert user_data["lastName"] == "Rodrigues"

0 commit comments

Comments
 (0)