Skip to content

Make dkit errors --search case-insensitive (#73) - #82

Merged
Bytewave1 merged 2 commits into
Bytewave1:mainfrom
Ashu-t021:fix-errors-search-case-insensitive
Oct 28, 2026
Merged

Bytewave1 merged 2 commits into
Bytewave1:mainfrom
Ashu-t021:fix-errors-search-case-insensitive

Conversation

@Ashu-t021

Copy link
Copy Markdown
Contributor

Closes #73

Summary of changes

  • Updated _search in src/dkit/commands/errors.py to use .casefold() for case-insensitive matching across error types, codes, and descriptions.
  • Updated CLI option help text and description string in src/dkit/commands/errors.py to reflect case-insensitivity.
  • Updated test assertions in tests/test_errors.py to test case-insensitive search behavior.
  • Verified 100% line and branch test coverage for errors.py.
  • Updated CHANGELOG.md under [Unreleased].
  • Formatted and linted with Ruff.

@Bytewave1 Bytewave1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @Ashu-t021, the fix itself is correct: I checked --search missing, Missing and MISSING (3 results each), HTTP, 5XX and an empty search (still exit 2). Tests are green with 100 % coverage and ruff is clean.

I ran mutation tests on _search and some mutations survive, which means a few ways to break the behaviour are not covered yet:

  • only lower-casing the search text but not the searched text (so --search missing would no longer find "Missing access")
  • applying casefold() to only some of the fields (type, code, description), not all three
  • echoing a changed query in the JSON output

Please add this test (or an equivalent one) to tests/test_errors.py:

def test_cli_errors_search_ignores_case_in_every_field(cli) -> None:
    # description: "Missing access" is stored with a capital M
    missing = cli("--json", "errors", "--search", "missing").json
    assert "50001" in [entry["code"] for entry in missing["error_codes"]]
    # type: stored in lower case, and 404 does not contain "http" in its text
    http = cli("--json", "errors", "--search", "HTTP").json
    assert "404" in [entry["code"] for entry in http["error_codes"]]
    # code: stored as "5xx"
    five = cli("--json", "errors", "--search", "5XX").json
    assert "5xx" in [entry["code"] for entry in five["error_codes"]]
    # the query is echoed as typed
    assert five["query"] == "5XX"

Small CHANGELOG fixes: there is trailing whitespace on the new bullet (git diff --check reports it), and the other blocks have an empty line between the ### Changed heading and the first bullet. Please also end the bullet like the others, for example:

@Ashu-t021

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've added the mutation test covering all three fields and query echoing to tests/test_errors.py, cleaned up the trailing whitespace, and formatted the entry under ### Changed in CHANGELOG.md.

@Bytewave1 Bytewave1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, this looks good. --search is now case-insensitive across type, code and description, the tests cover each field, and the changelog entry is in the right place.

@Bytewave1
Bytewave1 merged commit b290c31 into Bytewave1:main Oct 28, 2026
@Bytewave1

Copy link
Copy Markdown
Owner

Thanks @Ashu-t021, merged! This also fixes #73. Nice work on picking up the review notes so quickly.

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.

dkit errors: make --search case-insensitive like locales and scopes

2 participants