You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
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.
The text was updated successfully, but these errors were encountered:
Current Behavior
Running
Client.search
orFilestoreBackend.search
with anattr
that is does not exist (such as a typo) doesn't notify the user that theattr
does not exist. It returns no entries, but this is also the case ifattr
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 anattr
that they think exists.Suggested Solution
A few ideas:
Entry.__subclass__
to inspect annotations for allEntry
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.attr
. This slots in to the logic forFilestoreBackend.search
, but would require separate handling for database backends. It also finishes the entire search before concluding whether eachattr
is valid, so throwing an error would be wasteful and I would probably go with logging a warning instead.attr
s. 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.The text was updated successfully, but these errors were encountered: