datafoodconsortium / prototype

The DFC prototype allows you to map data on different platforms.
http://proto.datafoodconsortium.org/
MIT License
10 stars 4 forks source link

Saving changes fails #136

Closed mkllnk closed 1 year ago

mkllnk commented 1 year ago

Description

I'm updating the Open Food Network application to the newest DFC version. Import the catalog works but updating an items fails.

Expected Behavior

I was expecting PATCH requests to the OFN server like in the past.

Actual Behaviour

No requests sent to the OFN server. The network requests within the prototype:

OPTIONS /data/core/catalog/reconciled/ HTTP/1.1
Host: proto.datafoodconsortium.org:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: */*
Accept-Language: en,en-US;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization,content-type
Referer: http://proto.datafoodconsortium.org/
Origin: http://proto.datafoodconsortium.org
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
POST /data/core/catalog/reconciled/ HTTP/1.1
Host: proto.datafoodconsortium.org:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: */*
Accept-Language: en,en-US;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://proto.datafoodconsortium.org/
authorization: JWT token
content-type: application/json
Origin: http://proto.datafoodconsortium.org
Content-Length: 244
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

{"message":"Invalid JSON-LD syntax; \"@id\" value an empty object or array of strings, if framing"}

Steps to Reproduce

  1. Import catalog from OFN FR Staging.
  2. Update a field of an imported product.

The OFN platform provided this data when importing:

{"@context":{"rdfs":"http://www.w3.org/2000/01/rdf-schema#","skos":"http://www.w3.org/2004/02/skos/core#","dfc":"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#","dc":"http://purl.org/dc/elements/1.1/#","dfc-b":"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#","dfc-p":"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductGlossary.owl#","dfc-t":"https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#","dfc-m":"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#","dfc-pt":"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#","dfc-f":"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#","ontosec":"http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#","dfc-p:hasUnit":{"@type":"@id"},"dfc-b:hasUnit":{"@type":"@id"},"dfc-b:hasQuantity":{"@type":"@id"},"dfc-p:hasType":{"@type":"@id"},"dfc-b:hasType":{"@type":"@id"},"dfc-b:references":{"@type":"@id"},"dfc-b:referencedBy":{"@type":"@id"},"dfc-b:offeres":{"@type":"@id"},"dfc-b:supplies":{"@type":"@id"},"dfc-b:defines":{"@type":"@id"},"dfc-b:affiliates":{"@type":"@id"},"dfc-b:hasCertification":{"@type":"@id"},"dfc-b:manages":{"@type":"@id"},"dfc-b:offeredThrough":{"@type":"@id"},"dfc-b:hasBrand":{"@type":"@id"},"dfc-b:hasGeographicalOrigin":{"@type":"@id"},"dfc-b:hasClaim":{"@type":"@id"},"dfc-b:hasAllergenDimension":{"@type":"@id"},"dfc-b:hasNutrientDimension":{"@type":"@id"},"dfc-b:hasPhysicalDimension":{"@type":"@id"},"dfc:owner":{"@type":"@id"},"dfc-t:hostedBy":{"@type":"@id"},"dfc-t:hasPivot":{"@type":"@id"},"dfc-t:represent":{"@type":"@id"}},"@graph":[{"@id":"https://staging.coopcircuits.fr/api/dfc-v1.7/persons/21208","@type":"dfc-b:Person","dfc-b:affiliates":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731"},{"@id":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731","@type":"dfc-b:Enterprise","dfc-b:hasName":"","dfc-b:hasDescription":"","dfc-b:VATnumber":"","dfc-b:supplies":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/supplied_products/56790","dfc-b:manages":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/catalog_items/56790"},{"@id":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/catalog_items/56790","@type":"dfc-b:CatalogItem","dfc-b:references":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/supplied_products/56790","dfc-b:sku":"nana","dfc-b:stockLimitation":7,"dfc-b:offeredThrough":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/offers/56790"},{"@id":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/supplied_products/56790","@type":"dfc-b:SuppliedProduct","dfc-b:name":"Banana","dfc-b:description":"Delicious bananas, travelled well","dfc-b:hasType":"http://static.datafoodconsortium.org/data/productTypes.rdf#non-local-vegetable","dfc-b:hasQuantity":{"@type":"dfc-b:QuantitativeValue","dfc-b:hasUnit":"dfc-m:Gram","dfc-b:value":2000.0},"dfc-b:alcoholPercentage":0.0,"dfc-b:lifetime":"","dfc-b:usageOrStorageCondition":"","dfc-b:totalTheoreticalStock":0.0},{"@id":"https://staging.coopcircuits.fr/api/dfc-v1.7/enterprises/2731/offers/56790","@type":"dfc-b:Offer","dfc-b:price":3.0,"dfc-b:stockLimitation":7}]}

Animated Gif/Screenshot

Workaround

Your Environment

The DFC prototype just says V3.6.

The OFN staging server was running the branch from this pull request:

simonLouvet commented 1 year ago

hello @mkllnk .

http PATCH verb is complexe in LDP standard and is open to interpretation. To avoid this interpretation, the prototype will now use the http PUT verb.

simonLouvet commented 1 year ago

POST methode at /data/core/catalog/reconciled/ is used to update recocield product (dfc product). APi used by prototype front.

mkllnk commented 1 year ago

http PATCH verb is complexe in LDP standard and is open to interpretation. To avoid this interpretation, the prototype will now use the http PUT verb.

Okay, that's fine. But just to clarify that the problem I saw was no request at all to the OFN platform. So the symptoms are:

simonLouvet commented 1 year ago

@mkllnk I reproduced the bug on the proto. Internally exception before sending the PUT. I'm trying to fix it this week.

simonLouvet commented 1 year ago

image

simonLouvet commented 1 year ago

@mkllnk fix brand was not provided by OFN fr and code used it