Partkeepr: Error Scanning when using part ID

Created on 14 Nov 2017  ·  4Comments  ·  Source: partkeepr/PartKeepr

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]

Bug

Most helpful comment

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

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

All 4 comments

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?

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...

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

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

public function setProperty($property)
{
    $this->property = str_replace("@", "", $property);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

HolgerHeckeroth picture HolgerHeckeroth  ·  4Comments

olewolf picture olewolf  ·  18Comments

FinalHopee picture FinalHopee  ·  32Comments

michielbrink picture michielbrink  ·  7Comments

Gasman2014 picture Gasman2014  ·  26Comments