partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.4k stars 403 forks source link

Error Scanning when using part ID #924

Open integralmedia opened 7 years ago

integralmedia commented 7 years ago

I'm using PartKeepr 1.3.0

I have an issue with scanning barcodes to open up the modify part dialog.

I created Barcodes with Prefix "PID-"+The Part Unique ID

I setup code "PID-" in PartKeepr with "Search Part" as the Action, and then selected PartKeepr.PartBundle.Entity.Part.@id as the Search Field.

I am able to scan other barcodes for Storage Locations and those open up the query for parts in the location as expected. This seems to be specific to the Part Lookup.

When I scan a barcode for example "PID-12" PartKeepr responds to the scan but displays the following error:

Details

[Syntax Error] line 0, col 83: Error: Expected =, <, <=, <>, >, >=, !=, got 'id'

Request

GET http://192.168.0.196/parts/web/api/parts?_dc=1510689688405

Response Status Code

500

Response

{"@context":"\/parts\/web\/api\/contexts\/Error","@type":"Error","hydra:title":"An error occurred","hydra:description":"[Syntax Error] line 0, col 83: Error: Expected =, \u003C, \u003C=, \u003C\u003E, \u003E, \u003E=, !=, got \u0027id\u0027"}

Server Configuration

doctrine_orm_version: 2.5.4 doctrine_dbal_version: 2.5.2 doctrine_common_version: 2.6.0-DEV php_version: 7.0.22-0ubuntu0.16.04.1 auto_start_session: true maxUploadSize: 2097152 isOctoPartAvailable: false availableImageFormats: JPG,GIF,PNG max_users: unlimited authentication_provider: PartKeepr.Auth.HTTPBasicAuthenticationProvider tip_of_the_day_uri: https://partkeepr.org/tips/%s password_change: true patreonStatus: [object Object]

integralmedia commented 7 years ago

I think I know what's happening here but no idea how to resolve. It appears that an @ is being prepended to the id variable in the GET request.

When that happens the error occurs, if I modify the get request and remove that @ symbol I get a response that looks like this:

{"@context":"\/parts\/web\/api\/contexts\/Part","@id":"\/parts\/web\/api\/parts?_dc=1510773608949\u0026page=1\u0026start=0\u0026itemsPerPage=50\u0026group={"property":"categoryPath","direction":"ASC"}\u0026order=[{"property":"category.categoryPath","direction":"ASC"},{"property":"name","direction":"ASC"}]\u0026filter=[{"subfilters":[{"subfilters":[],"property":"id","operator":"LIKE","value":"43W"}],"type":"OR"}]","@type":"hydra:PagedCollection","hydra:totalItems":0,"hydra:itemsPerPage":50,"hydra:firstPage":"\/parts\/web\/api\/parts?_dc=1510773608949\u0026start=0\u0026itemsPerPage=50\u0026group={"property":"categoryPath","direction":"ASC"}\u0026order=[{"property":"category.categoryPath","direction":"ASC"},{"property":"name","direction":"ASC"}]\u0026filter=[{"subfilters":[{"subfilters":[],"property":"id","operator":"LIKE","value":"43W"}],"type":"OR"}]","hydra:lastPage":"\/parts\/web\/api\/parts?_dc=1510773608949\u0026start=0\u0026itemsPerPage=50\u0026group={"property":"categoryPath","direction":"ASC"}\u0026order=[{"property":"category.categoryPath","direction":"ASC"},{"property":"name","direction":"ASC"}]\u0026filter=[{"subfilters":[{"subfilters":[],"property":"id","operator":"LIKE","value":"43W"}],"type":"OR"}]","hydra:member":[],"hydra:search":{"@type":"hydra:IriTemplate","hydra:template":"\/parts\/web\/api\/parts{?}","hydra:variableRepresentation":"BasicRepresentation","hydra:mapping":[]}}

This looks like it returns the right response telling the UI to invoke a lookup query...?

So I guess the question is how can we limit this @ from being included in the GET query on the barcode scan?

integralmedia commented 7 years ago

Ok, as much as this is not a solution, I did find a work around.

I had to modify the following file and everything works now, I'm able to scan the item id and the lookup works as expected:

/src/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php

Modify line 353 From:

$filter->setProperty($data->property); To: $filter->setProperty(str_replace("@","",$data->property));

Basically it's the @ symbol that is causing the problem and it needs to be removed from the GET Ajax request. I'm not exactly sure where to make that change but this doing the above did work for me as a temporary fix until someone can chime in as to how to achieve this properly...

kuon commented 6 years ago

Got the same issue, seems to be the same than https://github.com/partkeepr/PartKeepr/issues/894

j123b567 commented 6 years ago

Better workaround is to replace property name directly in src/PartKeepr/DoctrineReflectionBundle/Filter/AssociationPropertyTrait.php

public function setProperty($property)
{
    $this->property = str_replace("@", "", $property);
}