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

Fix internal server error when providing an association as the filter param #1052

Merged
merged 2 commits into from
Jun 12, 2019

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented Jun 11, 2019

Issue/Task Number: #1051

Overview

This PR fixes a specific case of filtering when an association name is given as the filter param without specifying the association's field.

Changes

  • Add a guard so association filters do not get processed as a field.

Implementation Details

Overlay filters could be in the form of:

[
  some_field: nil,
  some_id: :uuid,
  some_assoc: [:id, :name]
]

So when an association is given as a filter param without its dot-notated subfield, e.g. field: "some_assoc" instead of field: "some_assoc.id", it treats [:id, :name] as a field type like :uuid instead of a list of associated subfields, and hence the internal server error.

An is_list(type) guard is added to catch the association and return : missing_subfield for further processing by the parser and orchestrator.

Usage

Try the request in #1051. Its return should be similar to:

{
  "version": "1",
  "success": false,
  "data": {
    "object": "error",
    "messages": null,
    "description": "Invalid parameter provided. The queried field must refer to the object's field, not the object. Given: 'from_wallet'.",
    "code": "client:invalid_parameter"
  }
}

Impact

No changes to the API specs or DB schema.

@unnawut unnawut added this to the v1.2 milestone Jun 11, 2019
@unnawut unnawut self-assigned this Jun 11, 2019
@unnawut unnawut added this to In Progress in eWallet Jun 11, 2019
@unnawut unnawut moved this from In Progress to Review in eWallet Jun 11, 2019
@unnawut unnawut merged commit 827e21e into omgnetwork:v1.2 Jun 12, 2019
eWallet automation moved this from Review to Done Jun 12, 2019
@unnawut unnawut deleted the 1051-filter-assoc branch June 12, 2019 07:10
jarindr added a commit that referenced this pull request Jun 18, 2019
* Update user and admin (#1035)

* add update admin service

* done edit global role

* update user

* fix action

* default ID user

* remove legacy

* add alert

* Fix admin panel url in seeding (#1038)

* Fix internal server error when providing an association as the filter param (#1052)

* fix input

* remove log

* fix lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
eWallet
  
5-Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants