Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: alert the user when a SearchTerm has an attr that does not exist #83

Open
shilorigins opened this issue Sep 18, 2024 · 0 comments
Open

Comments

@shilorigins
Copy link
Collaborator

Current Behavior

Running Client.search or FilestoreBackend.search with an attr that is does not exist (such as a typo) doesn't notify the user that the attr does not exist. It returns no entries, but this is also the case if attr does exist but no entry has an appropriate value.

Expected Behavior

Searching for a nonexistent attr should alert the user in some way.

Context / environment

Alerting the user will help in cases where a user is programming with the client directly and mistype an attr or search for an attr that they think exists.

Suggested Solution

A few ideas:

  1. Use Entry.__subclass__ to inspect annotations for all Entry types and discover their attributes. This avoids the need to instantiate empty instances to discover instance attrs, but it also discovers class attrs that won't be recorded in the backend and includes attrs we don't care to search on (e.g. abs_tolerance). This isn't really what annotations are for either, so it's kludgy.
  2. During the search, record whether any entry ever has attr. This slots in to the logic for FilestoreBackend.search, but would require separate handling for database backends. It also finishes the entire search before concluding whether each attr is valid, so throwing an error would be wasteful and I would probably go with logging a warning instead.
  3. Define a set of valid attrs. This fits into an idea where the UI could dynamically represent search options by receiving some definition of attrs, operators, and expected types, but fleshing out that system will take some work and will be easier when we have a second backend type to inform the design. It also has some manual duplication, which only becomes worthwhile if it's part of a larger feature.
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

No branches or pull requests

1 participant