Name filters use istartswith on most endpoints — substring search misses; inconsistent with activations/rulebooks
- Dominant language
- Python
- Stars
- 93
- Forks
- 76
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 14
Description
### Please confirm the following
- [x] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [x] I have checked the [current issues](https://github.com/ansible/eda-server/issues) for duplicates.
- [x] I understand that EDA-Controller is open source software provided for free and that I might not receive a timely response.
### Bug Summary
Six of the nine list endpoints used by the EDA role wizard filter `name` with `lookup_expr="istartswith"`, while three use `icontains`, so substring search silently misses on most endpoints — and the ansible-ui toolbar presents the filter as a "contains" search:
| Endpoint | `name` lookup |
|---|---|
| eda-credentials, projects, credential-types, decision-environments, event-streams | `istartswith` |
| activations, rulebooks, activation-instances | `icontains` |
| audit-rules | no `filterset_class` at all |
(See `src/aap_eda/api/filters/*.py`.)
Clients also cannot work around this with `?name__icontains=`: no FilterSet declares that lookup, and with no django-filter STRICTNESS configured the unknown param is silently ignored, returning the full unfiltered list.
### Environment
AAP 2.7 on OpenShift (eda-server-operator), EDA API version 1.3.2. Behavior is defined in the FilterSet declarations, so it is deployment-independent (same in standalone builds).
### Steps to reproduce
1. On an instance with the default credential types loaded, call `GET /api/eda/v1/credential-types/?name=auth`.
2. Call `GET /api/eda/v1/credential-types/?name__icontains=basic`.
### Actual results
1. `?name=auth` returns 0 results, even though "OAuth2 Event Stream" and "OAuth2 JWT Event Stream" exist (prefix-only match).
2. `?name__icontains=basic` returns all 28 credential types (param silently ignored, no filtering).
### Expected results
1. A name search presented as "contains" in the UI should match substrings: `?name=auth` should return the two OAuth2 types.
2. Ideally an unsupported filter param should not silently return the full unfiltered collection.
### Additional information
Suggested fix: change `lookup_expr` to `icontains` for the `istartswith` name filters (precedent already in-tree: `ActivationFilter`, `RulebookFilter`), and consider adding a `filterset_class` to `AuditRuleViewSet`. Backward-compatible: `icontains` matches are a strict superset of `istartswith` matches.
Refs: ansible/ansible-ui#3322 (where this was uncovered), ansible/django-ansible-base#1060 (related OPTIONS metadata regression found in the same investigation).
Contributor guide
Research direction
Start in src/aap_eda/api/filters/*.py and compare the name FilterSet declarations for the listed endpoints with ActivationFilter and RulebookFilter. Review the AuditRuleViewSet entry point, then verify the credential-types requests in the issue and confirm that substring searches consistently return matching results without changing unrelated filtering behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100