Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Fix error 500 when trying to filter a disallowed field on /api/admin/account.get_wallets #514

Merged
merged 4 commits into from
Nov 12, 2018

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented Nov 9, 2018

Closes #513

Overview

This PR fixes the issue with filtering a disallowed field on /api/admin/account.get_wallets.

Changes

  • Updated Orchestrator.build_query/3 to use with clause instead of pipes to catch errors mid-way.
  • Fixed WalletOverlay that should use self_filter_fields() instead of default_preload_assocs() for figuring out the allowed filter fields.

Implementation Details

Because Orchestrator.build_query/3 was using pipes, this makes it hard to handle error if it is returned midway. This PR changed it to use with clauses.

Also, WalletOverlay was using default_preload_assocs() to build the filters instead of self_filter_fields().

Usage

Making a request like following should return the proper results:

curl 10.5.10.10:4000/api/admin/account.get_wallets \
-H "Accept: application/vnd.omisego.v1+json" \
-H "Authorization: OMGAdmin <truncated>" \
-H "Content-Type: application/json" \
-d '{
  "per_page":10,
  "sort_by":"created_at",
  "sort_dir":"desc",
  "id":"acc_01cvven6b8zchchcn3wpsk9h89",
  "owned":false,
  "match_any": [
    {"field":"address","comparator":"contains","value":"asasd"},
    {"field":"account.name","comparator":"contains","value":"asasd"}
  ]
}' \
-v -w "\n" | jq

Impact

No DB or API changes

@ghost ghost added the s2/wip 🚧 label Nov 12, 2018
@unnawut unnawut merged commit bdba813 into master Nov 12, 2018
@ghost ghost removed the s2/wip 🚧 label Nov 12, 2018
@unnawut unnawut deleted the 513-filter-error500 branch November 12, 2018 07:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error 500 when filtering on /api/admin/account.get_wallets
4 participants