Repository navigation
Make dkit errors --search case-insensitive (#73) - #82
Conversation
Bytewave1
left a comment
There was a problem hiding this comment.
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 missingwould no longer find "Missing access") - applying
casefold()to only some of the fields (type, code, description), not all three - echoing a changed
queryin 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:
|
Thanks for the review! I've added the mutation test covering all three fields and query echoing to |
Bytewave1
left a comment
There was a problem hiding this comment.
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.
|
Thanks @Ashu-t021, merged! This also fixes #73. Nice work on picking up the review notes so quickly. |
Closes #73
Summary of changes
_searchinsrc/dkit/commands/errors.pyto use.casefold()for case-insensitive matching across error types, codes, and descriptions.src/dkit/commands/errors.pyto reflect case-insensitivity.tests/test_errors.pyto test case-insensitive search behavior.errors.py.CHANGELOG.mdunder[Unreleased].