Skip to content

fix: return empty list on ValueError in _get_commands_list_from_settings#2275

Open
wishhyt wants to merge 1 commit intoqodo-ai:mainfrom
wishhyt:fix/bitbucket-server-missing-return
Open

fix: return empty list on ValueError in _get_commands_list_from_settings#2275
wishhyt wants to merge 1 commit intoqodo-ai:mainfrom
wishhyt:fix/bitbucket-server-missing-return

Conversation

@wishhyt
Copy link
Copy Markdown

@wishhyt wishhyt commented Mar 18, 2026

Summary

  • _get_commands_list_from_settings() catches ValueError and logs the error, but has no return statement in the except block, causing the function to implicitly return None
  • Callers use .extend() on the return value, which raises TypeError: 'NoneType' object is not iterable when the result is None
  • This causes the entire webhook processing flow to fail when settings are misconfigured

Changes

pr_agent/servers/bitbucket_server_webhook.py: Added return [] to the except ValueError block

Test plan

  • Verify that Bitbucket Server webhook processing continues gracefully when settings retrieval fails
  • Verify normal settings retrieval still returns the expected command list

When `get_settings().get()` raises ValueError, the except block logs
the error but has no return statement, causing the function to
implicitly return None. Callers use `.extend()` on the result, which
raises TypeError on None. Return an empty list instead.

Made-with: Cursor
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix missing return statement in _get_commands_list_from_settings

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix missing return statement in exception handler
• Prevents TypeError when settings retrieval fails
• Allows webhook processing to continue gracefully
• Minor formatting improvement to function signature
Diagram
flowchart LR
  A["_get_commands_list_from_settings called"] --> B{"get_settings().get() succeeds?"}
  B -->|Yes| C["Return command list"]
  B -->|No ValueError| D["Log error"]
  D --> E["Return empty list"]
  C --> F["Caller uses .extend()"]
  E --> F
Loading

Grey Divider

File Changes

1. pr_agent/servers/bitbucket_server_webhook.py 🐞 Bug fix +2/-1

Add missing return statement in exception handler

• Added return [] statement in the ValueError exception handler
• Fixed function signature formatting by removing extra space before colon
• Ensures function always returns a list instead of None
• Prevents TypeError when callers use .extend() on the result

pr_agent/servers/bitbucket_server_webhook.py


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Mar 18, 2026

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. No tests for new return [] 📘 Rule violation ⛯ Reliability
Description
The PR changes behavior to return an empty list on ValueError, but no pytest coverage was
added/updated to prevent regressions. This can allow webhook processing to break again if the
error-handling path changes.
Code

pr_agent/servers/bitbucket_server_webhook.py[R246-251]

+def _get_commands_list_from_settings(setting_key: str) -> list:
    try:
        return get_settings().get(setting_key, [])
    except ValueError as e:
        get_logger().error(f"Failed to get commands list from settings {setting_key}: {e}")
+        return []
Evidence
PR Compliance ID 14 requires adding/updating pytest coverage for behavior changes. The diff shows a
functional behavior change in _get_commands_list_from_settings() (now returning [] in the
exception path) and the PR description indicates only this production file was modified, with no
accompanying tests added.

AGENTS.md
pr_agent/servers/bitbucket_server_webhook.py[246-251]

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

## Issue description
A behavior change was introduced in `_get_commands_list_from_settings()` (return `[]` on `ValueError`), but no pytest coverage was added to lock in the new behavior.

## Issue Context
Callers `.extend()` the returned value; regression back to `None` or an uncaught exception would break webhook processing.

## Fix Focus Areas
- pr_agent/servers/bitbucket_server_webhook.py[246-251]
- tests/unittest/test_bitbucket_server_webhook.py[1-200]

ⓘ 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

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.

1 participant