account_objects: Disallow filtering by types that an account can't own. #4681
Labels
API Change
Bug
Clio Reviewed
Feature Request
Used to indicate requests to add new features
Good First Issue
Great issue for a new contributor
Inspired by #4678, it would reduce confusion if the
account_objects
API method threw an error in cases where the user attempted to filter by a ledger entry type that accounts can't own.(Note: Clio already does this. The documentation has always omitted mention of the types that accounts can't own.)
Summary
The
account_objects
method uses shared code to allow the user to specify atype
of ledger entry and filter results to only the given type.Some types, like the
Amendments
table, can't be owned by any account, so specifying that type inaccount_objects
always returns an empty list. It might even be a paginated empty list, since the API implementation currently—as best I can tell—needs to walk the entire owner directory to confirm that no entry of the given type is present; it doesn't have a concept of which entries can or can't be present.Source file:
AccountObjects.cpp
Example request:
Motivation
Users may be confused why they get no results if they expect something to appear that isn't there (this came up with AMM). An error more clearly explains the situation. Also, if they do, the server does extra work looking for something that doesn't exist.
Solution
The following types cannot ever appear in an owner directory, and should return an
invalidParams
error if the user specifies their short name in thetype
field of anaccount_objects
request (short name in parens is what the user would specify for the command—see also #4393):amendments
)directory
)fee
)hashes
)Currently it's TBD whether or not an AMM entry gets added to the associated AMM-account's owner directory, but if not, it should be excluded also.
Filtering in the
ledger
andledger_data
methods should be unaffected. Those methods can return full ledger data, which does include these entry types, so it makes sense to allow filtering on them there.Notes on API Compatibility
Because (a) the Clio API already works this way, and (b) the documentation only lists the types that can appear and would still be considered valid, I consider this a non-breaking change and think it does not need to be put on an API version switch.
The text was updated successfully, but these errors were encountered: