Skip to content

client session updation#433

Merged
Bala-Sakabattula merged 2 commits intorelease-engineering:uat-instancefrom
Bala-Sakabattula:client-session-updation
Feb 23, 2026
Merged

client session updation#433
Bala-Sakabattula merged 2 commits intorelease-engineering:uat-instancefrom
Bala-Sakabattula:client-session-updation

Conversation

@Bala-Sakabattula
Copy link
Collaborator

@Bala-Sakabattula Bala-Sakabattula commented Feb 18, 2026

I updated the Jira client call used for checking service availability from session() to server_info() as the session() function is depreciated and will be removed soon.

@qodo-code-review
Copy link

Review Summary by Qodo

Replace deprecated session() with server_info() for auth validation

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace deprecated session() call with server_info() for authentication validation
• Update authentication check to use non-deprecated Jira REST endpoint
• Align with Atlassian's deprecation notice for cookie-based authentication
• Update corresponding unit tests to mock new server_info() method
Diagram
flowchart LR
  A["Deprecated session() endpoint"] -->|"Replace with"| B["server_info() endpoint"]
  B -->|"Validates authentication"| C["Non-deprecated REST API"]
  D["Unit tests"] -->|"Update mocks"| E["server_info() method"]
Loading

Grey Divider

File Changes

1. sync2jira/downstream_issue.py ✨ Enhancement +2/-1

Update authentication validation to use server_info

• Replace client.session() call with client.server_info() in get_jira_client() function
• Add explanatory comment about using non-deprecated endpoint
• Maintains same authentication validation behavior with updated API

sync2jira/downstream_issue.py


2. tests/test_downstream_issue.py 🧪 Tests +4/-4

Update test mocks for server_info method

• Update test_get_jira_client() to mock server_info() instead of session()
• Update test_get_jira_client_auth_failure() to mock server_info() side effect
• Ensure test assertions verify server_info() is called once in both test cases

tests/test_downstream_issue.py


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Feb 18, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. server_info() bypasses auth validation🐞 Bug ✓ Correctness
Description
client.server_info() calls /rest/api/2/serverInfo, a publicly accessible Jira Cloud endpoint
that returns HTTP 200 regardless of credential validity. This means misconfigured or invalid
credentials will silently pass the auth check in get_jira_client(), and all downstream
authenticated API calls will fail with confusing, context-free errors instead of a clear auth
failure at client initialization time.
Code

sync2jira/downstream_issue.py[R296-297]

+    # Validate authentication (server_info uses a non-deprecated endpoint; /rest/auth/1/session is deprecated)
+    client.server_info()
Evidence
The codebase itself proves the semantic mismatch: check_jira_status() already uses server_info()
exclusively as a server-reachability probe (not an auth check), and is called separately at
downstream_issue.py:1417 and downstream_pr.py:214 for that purpose. The original client.session()
call carried an explicit comment guaranteeing auth validation; that guarantee is removed by this
change without a true equivalent replacement.

sync2jira/downstream_issue.py[216-230]
sync2jira/downstream_issue.py[295-297]
sync2jira/downstream_issue.py[1417-1417]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`client.server_info()` was introduced as a replacement for the deprecated `client.session()` to validate authentication after creating a JIRA client. However, `/rest/api/2/serverInfo` is a publicly accessible endpoint that returns HTTP 200 regardless of credential validity. This silently allows misconfigured clients to pass the auth check, causing all subsequent authenticated operations to fail with confusing errors.
## Issue Context
The original `client.session()` called `/rest/auth/1/session` which explicitly required valid credentials and raised `JIRAError` on failure. The replacement must also call an **authenticated** endpoint. The existing `check_jira_status()` function already uses `server_info()` as a server-reachability probe — using it again in `get_jira_client()` for auth validation is both semantically wrong and redundant.
## Fix Focus Areas
- `sync2jira/downstream_issue.py[297-297]` — replace `client.server_info()` with `client.myself()` and update the comment to reflect that `myself()` calls `/rest/api/2/myself`, which requires valid credentials and raises `JIRAError` on auth failure
- `tests/test_downstream_issue.py[161-161]` — update mock: `mock_jira_instance.myself.return_value = None`
- `tests/test_downstream_issue.py[172-172]` — update assertion: `mock_jira_instance.myself.assert_called_once()`
- `tests/test_downstream_issue.py[184-184]` — update side_effect: `mock_jira_instance.myself.side_effect = JIRAError("Authentication failed")`
- `tests/test_downstream_issue.py[195-195]` — update assertion: `mock_jira_instance.myself.assert_called_once()`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. server_info() bypasses auth validation🐞 Bug ✓ Correctness
Description
client.server_info() calls /rest/api/2/serverInfo, a publicly accessible Jira Cloud endpoint
that returns HTTP 200 regardless of credential validity. This means misconfigured or invalid
credentials will silently pass the auth check in get_jira_client(), and all downstream
authenticated API calls will fail with confusing, context-free errors instead of a clear auth
failure at client initialization time.
Code

sync2jira/downstream_issue.py[R296-297]

+    # Validate authentication (server_info uses a non-deprecated endpoint; /rest/auth/1/session is deprecated)
+    client.server_info()
Evidence
The codebase itself proves the semantic mismatch: check_jira_status() already uses server_info()
exclusively as a server-reachability probe (not an auth check), and is called separately at
downstream_issue.py:1417 and downstream_pr.py:214 for that purpose. The original client.session()
call carried an explicit comment guaranteeing auth validation; that guarantee is removed by this
change without a true equivalent replacement.

sync2jira/downstream_issue.py[216-230]
sync2jira/downstream_issue.py[295-297]
sync2jira/downstream_issue.py[1417-1417]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`client.server_info()` was introduced as a replacement for the deprecated `client.session()` to validate authentication after creating a JIRA client. However, `/rest/api/2/serverInfo` is a publicly accessible endpoint that returns HTTP 200 regardless of credential validity. This silently allows misconfigured clients to pass the auth check, causing all subsequent authenticated operations to fail with confusing errors.
## Issue Context
The original `client.session()` called `/rest/auth/1/session` which explicitly required valid credentials and raised `JIRAError` on failure. The replacement must also call an **authenticated** endpoint. The existing `check_jira_status()` function already uses `server_info()` as a server-reachability probe — using it again in `get_jira_client()` for auth validation is both semantically wrong and redundant.
## Fix Focus Areas
- `sync2jira/downstream_issue.py[297-297]` — replace `client.server_info()` with `client.myself()` and update the comment to reflect that `myself()` calls `/rest/api/2/myself`, which requires valid credentials and raises `JIRAError` on auth failure
- `tests/test_downstream_issue.py[161-161]` — update mock: `mock_jira_instance.myself.return_value = None`
- `tests/test_downstream_issue.py[172-172]` — update assertion: `mock_jira_instance.myself.assert_called_once()`
- `tests/test_downstream_issue.py[184-184]` — update side_effect: `mock_jira_instance.myself.side_effect = JIRAError("Authentication failed")`
- `tests/test_downstream_issue.py[195-195]` — update assertion: `mock_jira_instance.myself.assert_called_once()`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Misleading auth-check comment🐞 Bug ✓ Correctness
Description
get_jira_client() now calls client.server_info() with a comment claiming it only raises on
authentication failure, but the same call is used elsewhere as a general server-status probe and can
also fail for connectivity/availability reasons. This can mislead future error handling and
debugging when client creation fails (it may not be auth-related).
Code

sync2jira/downstream_issue.py[296]

+    client.server_info()  # This raises an exception if authentication was not successful
Evidence
The new comment asserts an auth-only failure mode, but the codebase already treats server_info()
as a general Jira health check where *any* exception indicates the server is not "up". Also,
sync_with_jira() calls get_jira_client() outside its retry/exception handling loop, so when
server_info() fails, the run aborts immediately—making accurate messaging/comments more important
for diagnosis.

sync2jira/downstream_issue.py[294-297]
sync2jira/downstream_issue.py[216-230]
sync2jira/downstream_issue.py[1388-1404]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`get_jira_client()` uses `client.server_info()` with a comment that implies the call only fails when authentication fails. In this repo, `server_info()` is also used as a generic Jira health/status check and can fail for other reasons (network, server down). This mismatch can confuse debugging and future exception handling.
### Issue Context
- `server_info()` is used in `check_jira_status()` as a general availability probe.
- `sync_with_jira()` calls `get_jira_client()` outside the retry loop, so failures during `server_info()` abort early; accurate context is helpful.
### Fix Focus Areas
- sync2jira/downstream_issue.py[294-297]
- sync2jira/downstream_issue.py[216-230]
- sync2jira/downstream_issue.py[1388-1404]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +296 to +297
# Validate authentication (server_info uses a non-deprecated endpoint; /rest/auth/1/session is deprecated)
client.server_info()

Choose a reason for hiding this comment

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

Action required

1. Server_info() bypasses auth validation 🐞 Bug ✓ Correctness

client.server_info() calls /rest/api/2/serverInfo, a publicly accessible Jira Cloud endpoint
that returns HTTP 200 regardless of credential validity. This means misconfigured or invalid
credentials will silently pass the auth check in get_jira_client(), and all downstream
authenticated API calls will fail with confusing, context-free errors instead of a clear auth
failure at client initialization time.
Agent Prompt
## Issue description
`client.server_info()` was introduced as a replacement for the deprecated `client.session()` to validate authentication after creating a JIRA client. However, `/rest/api/2/serverInfo` is a publicly accessible endpoint that returns HTTP 200 regardless of credential validity. This silently allows misconfigured clients to pass the auth check, causing all subsequent authenticated operations to fail with confusing errors.

## Issue Context
The original `client.session()` called `/rest/auth/1/session` which explicitly required valid credentials and raised `JIRAError` on failure. The replacement must also call an **authenticated** endpoint. The existing `check_jira_status()` function already uses `server_info()` as a server-reachability probe — using it again in `get_jira_client()` for auth validation is both semantically wrong and redundant.

## Fix Focus Areas
- `sync2jira/downstream_issue.py[297-297]` — replace `client.server_info()` with `client.myself()` and update the comment to reflect that `myself()` calls `/rest/api/2/myself`, which requires valid credentials and raises `JIRAError` on auth failure
- `tests/test_downstream_issue.py[161-161]` — update mock: `mock_jira_instance.myself.return_value = None`
- `tests/test_downstream_issue.py[172-172]` — update assertion: `mock_jira_instance.myself.assert_called_once()`
- `tests/test_downstream_issue.py[184-184]` — update side_effect: `mock_jira_instance.myself.side_effect = JIRAError("Authentication failed")`
- `tests/test_downstream_issue.py[195-195]` — update assertion: `mock_jira_instance.myself.assert_called_once()`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Bala-Sakabattula, are we really trying to validate our credentials here, or are we just trying to establish that the Jira service is available?

If it is the latter, then you should update your code comment to reflect that. If it is the former, then I guess we need to pick some other API method.

Regardless, we shouldn't refer to /rest/auth/1/session in the code (comment) going forward, since we no longer make that call. (When we look at this code next year or in the years after that, we won't care that, back in 2025, we used to call the session endpoint here!)

Choose a reason for hiding this comment

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

Code Implementation 🛠️

Implementation: Replace the post-client-construction auth validation call from server_info() (public endpoint) to myself() (authenticated endpoint), and update the accompanying comment to avoid referencing deprecated endpoints and to reflect the new intent.

Suggested change
# Validate authentication (server_info uses a non-deprecated endpoint; /rest/auth/1/session is deprecated)
client.server_info()
# Validate authentication using an authenticated endpoint.
# NOTE: server_info() may succeed even when credentials are invalid (e.g., Jira Cloud).
client.myself()

See review comment here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But client.server_info() fails if we have valid invalid creds as you can see in the doc as well it will return 401 unauthorized if creds are invalid.

https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-server-info/#api-rest-api-2-serverinfo-get

@webbnh I will change the comment part.

Choose a reason for hiding this comment

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

Question:

But client.server_info() fails if we have valid invalid creds as you can see in the doc as well it will return 401 unauthorized if creds are invalid. https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-server-info/#api-rest-api-2-serverinfo-get @webbnh I will change the comment part.

Answer:

""
relevant_sections: []
question_is_relevant: 0

webbnh

This comment was marked as resolved.

Copy link
Collaborator

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@webbnh
Copy link
Collaborator

webbnh commented Feb 19, 2026

/agentic_review

@qodo-code-review
Copy link

Persistent review updated to latest commit 0aae3c2

@Bala-Sakabattula Bala-Sakabattula merged commit 9abae4a into release-engineering:uat-instance Feb 23, 2026
6 checks passed
@Bala-Sakabattula Bala-Sakabattula deleted the client-session-updation branch February 23, 2026 16:19
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