Skip to content

Conversation

softctwo
Copy link

@softctwo softctwo commented Oct 21, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Snapshots:

Include snapshots for easier review.

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

google-labs-jules bot and others added 2 commits October 21, 2025 10:06
The `str_to_bool` function in `dbgpt.util.string_utils` had a bug where it would incorrectly return `True` for any string starting with "true".

This change corrects the logic to only accept exact matches for boolean-like strings.

Additionally, the function now raises a `ValueError` for any unrecognized string, making it more robust and preventing silent failures.

A new test file, `tests/unit_tests/test_string_utils.py`, has been added with comprehensive test cases to verify the corrected behavior.
@softctwo
Copy link
Author

This pull request improves the reliability of the str_to_bool function in string_utils.py by making its behavior stricter and more predictable. It also introduces comprehensive unit tests to verify correct handling of valid and invalid inputs.

Function behavior improvements:

  • The str_to_bool function now raises a ValueError for any input that does not exactly match accepted boolean strings, rather than returning False for all other cases. This prevents silent failures and makes error handling more explicit.

Testing enhancements:

  • Added a new test module test_string_utils.py with unit tests for str_to_bool, covering positive cases, negative cases, and edge cases where invalid input should raise a ValueError. This ensures the function behaves correctly for all expected and unexpected inputs.

@softctwo softctwo closed this Oct 21, 2025
@softctwo softctwo reopened this Oct 21, 2025
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