Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mcp_server/jira_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async def set_jira_fields(
"""
Updates the specified Jira issue, setting only the fields that are currently empty/unset.
"""
if os.getenv("SKIP_SETTING_JIRA_FIELDS", "False").lower() == "true":
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Checking for boolean environment variables by comparing to just 'true' can be brittle, as users might intuitively use other truthy values like '1' or 'yes'. It's more robust to check against a set of common truthy string values. This improvement could also be applied to the DRY_RUN check that follows.

Suggested change
if os.getenv("SKIP_SETTING_JIRA_FIELDS", "False").lower() == "true":
if os.getenv("SKIP_SETTING_JIRA_FIELDS", "False").lower() in ("true", "1", "yes"):

return "Skipping of setting Jira fields requested, not doing anything (this is expected, not an error)"
if os.getenv("DRY_RUN", "False").lower() == "true":
return "Dry run, not updating Jira fields (this is expected, not an error)"

Expand Down
1 change: 1 addition & 0 deletions mcp_server/tests/unit/test_jira_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def mocked_env():
flexmock(os).should_receive("getenv").with_args("JIRA_URL").and_return("http://jira")
flexmock(os).should_receive("getenv").with_args("JIRA_TOKEN").and_return("12345")
flexmock(os).should_receive("getenv").with_args("DRY_RUN", "False").and_return("false")
flexmock(os).should_receive("getenv").with_args("SKIP_SETTING_JIRA_FIELDS", "False").and_return("false")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

While this change correctly mocks the new environment variable for existing tests, the new functionality itself is not tested. A new test case should be added to verify that when SKIP_SETTING_JIRA_FIELDS is set to a truthy value, the set_jira_fields function returns the expected skip message and does not attempt to make any API calls to Jira. Untested code paths can introduce regressions in the future.



@pytest.mark.asyncio
Expand Down