regen-network / regen-web

:seedling: Website and marketplace application

Home Page:https://app.regen.network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anchored project metadata gets overwritten by unanchored project page metadata on create and edit project

S4mmyb opened this issue · comments

Describe the bug
When I used the project create form to create KSH01-001, I input the JSON-LD for the anchored metadata. When the project was created I noticed that none of it was populating in the additional info section. When I tried to edit the metadata post-project creation using the project edit form, I noticed that most of the metadata I submitted did not populate, and instead the JSON-LD anchored on-chain was a mix of the project page metadata and the anchored project metadata.

This is what I originally submitted:

{
  "@context": {
    "schema": "http://schema.org/",
    "regen": "https://schema.regen.network#",
    "qudt": "http://qudt.org/schema/qudt/",
    "unit": "http://qudt.org/vocab/unit/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "schema:url": {
      "@type": "schema:URL"
    },
    "qudt:unit": {
      "@type": "qudt:Unit"
    },
    "qudt:numericValue": {
      "@type": "xsd:double"
    },
    "regen:projectStartDate": {
      "@type": "xsd:date"
    },
    "regen:projectEndDate": {
      "@type": "xsd:date"
    },
    "regen:monitoringFrequency": {
      "@type": "schema:Duration"
    }
  },
  "@type": "regen:KSH01-Project",
  "schema:name": "Grgich Hills Estate Regenerative Sheep Grazing",
  "schema:location": {
    "@context": {
      "type": "@type",
      "@vocab": "https://purl.org/geojson/vocab#",
      "coordinates": {
        "@container": "@list"
      },
      "bbox": {
        "@container": "@list"
      }
    },
    "type": "Feature",
    "place_name": "Rutherford, California",
    "geometry": {
      "type": "Point",
      "coordinates": [
          -122.3754,
          38.4082
      ]
    }
  },
  "regen:projectSize": {
    "qudt:unit": "unit:HA",
    "qudt:numericValue": 126.6
  },
  "regen:projectActivity": "High Density, Short Duration Sheep Grazing",
  "regen:projectType": "Environmental Stewardship",
  "regen:projectStartDate": "2019-01-01",
  "regen:projectEndDate": "2023-05-31"
}

This is what was anchored:

{
  "@type":"regen:KSH01-Project",
  "@context":{
    "xsd":"http://www.w3.org/2001/XMLSchema#",
    "qudt":"http://qudt.org/schema/qudt/",
    "unit":"http://qudt.org/vocab/unit/",
    "regen":"https://schema.regen.network#",
    "schema":"http://schema.org/",
    "geojson":"https://purl.org/geojson/vocab#",
    "qudt:unit":{
      "@type":"qudt:Unit"
    },
    "regen:SDGs":{
      "@container":"@list"
    },
    "schema:url":{
      "@type":"schema:URL"
    },
    "schema:image":{
      "@type":"schema:URL"
    },
    "regen:ratings":{
      "@container":"@list"
    },
    "regen:videoURL":{
      "@type":"schema:URL"
    },
    "schema:location":{
      "@context":{
        "type":"@type",
        "@vocab":"https://purl.org/geojson/vocab#",
        "coordinates":{
          "@container":"@list"
        }
      }
    },
    "regen:boundaries":{
      "@type":"schema:URL"
    },
    "regen:coBenefits":{
      "@container":"@list"
    },
    "regen:glanceText":{
      "@container":"@list"
    },
    "qudt:numericValue":{
      "@type":"xsd:double"
    },
    "regen:ecosystemType":{
      "@container":"@list"
    },
    "regen:galleryPhotos":{
      "@container":"@list"
    },
    "regen:sectoralScope":{
      "@container":"@list"
    },
    "regen:certifications":{
      "@container":"@list"
    },
    "regen:cfcProjectPage":{
      "@type":"schema:URL"
    },
    "regen:cfcVintageYear":{
      "@type":"xsd:gYear"
    },
    "regen:projectEndDate":{
      "@type":"xsd:date"
    },
    "regen:vcsProjectPage":{
      "@type":"schema:URL"
    },
    "regen:landStewardPhoto":{
      "@type":"schema:URL"
    },
    "regen:projectStartDate":{
      "@type":"xsd:date"
    },
    "schema:itemListElement":{
      "@container":"@list"
    },
    "regen:projectActivities":{
      "@container":"@list"
    },
    "regen:verificationReports":{
      "@container":"@list"
    },
    "regen:landManagementActions":{
      "@container":"@list"
    },
    "regen:projectDesignDocument":{
      "@type":"schema:URL"
    },
    "regen:cfcCreditSerialNumbers":{
      "@container":"@list"
    },
    "regen:offsetGenerationMethod":{
      "@container":"@list"
    },
    "regen:additionalCertifications":{
      "@container":"@list"
    }
  },
  "schema:name":"Grgich Hills Estate Regenerative Sheep Grazing",
  "schema:location":{
    "id":"locality.485542636",
    "bbox":{
      "@list":[
        -122.4399677,
        38.4446282,
        -122.4078544,
        38.469967
      ]
    },
    "text":"Rutherford",
    "type":"Feature",
    "center":[
      -122.422479,
      38.458521
    ],
    "context":[
      {
        "id":"place.226216172",
        "text":"Napa",
        "wikidata":"Q60537",
        "mapbox_id":"dXJuOm1ieHBsYzpEWHZJN0E"
      },
      {
        "id":"district.16721644",
        "text":"Napa County",
        "wikidata":"Q108137",
        "mapbox_id":"dXJuOm1ieHBsYzoveWJz"
      },
      {
        "id":"region.419052",
        "text":"California",
        "wikidata":"Q99",
        "mapbox_id":"dXJuOm1ieHBsYzpCbVRz",
        "short_code":"US-CA"
      },
      {
        "id":"country.8940",
        "text":"United States",
        "wikidata":"Q30",
        "mapbox_id":"dXJuOm1ieHBsYzpJdXc",
        "short_code":"us"
      }
    ],
    "geometry":{
      "type":"Point",
      "coordinates":[
        -122.3754,
        38.4082
      ]
    },
    "relevance":1,
    "place_name":"Rutherford, California",
    "place_type":"locality",
    "properties":{
      "wikidata":"Q3111096",
      "mapbox_id":"dXJuOm1ieHBsYzpIUERLN0E"
    }
  },
  "regen:projectSize":{
    "qudt:unit":"unit:HA",
    "qudt:numericValue":126.6
  },
  "regen:projectType":"Environmental Stewardship",
  "regen:projectEndDate":"2023-05-31",
  "regen:projectActivity":"High Density, Short Duration Sheep Grazing",
  "regen:projectDeveloper":{
    "@type":"regen:Individual",
    "schema:name":"Regen Registry Credit Issuer",
    "regen:address":"regen1v2ncquer9r2ytlkxh2djmmsq3e8we6rjc9snfn",
    "schema:description":"This address issues credits for Credit Classes on Regen Registry where Credit Administration functions have been delegated to Regen Registry                    ",
    "http://schema.org/image":"https://regen-registry.s3.amazonaws.com/profiles/ad5a126e-d7bf-11ed-b9d8-0a6e1e09fcad/1681230075630/avatar.png"
  },
  "regen:projectStartDate":"2019-01-01",
  "https://schema.regen.network#galleryPhotos":[
    {
      "schema:url":"https://regen-registry.s3.amazonaws.com/projects/d1a8c4ec-4cf6-11ee-9623-0a6e1e09fcad/1694034306673-paigegreen_03.jpg",
      "schema:caption":"",
      "schema:creditText":"Paige Green Photography"
    },
    {
      "schema:url":"https://regen-registry.s3.amazonaws.com/projects/d1a8c4ec-4cf6-11ee-9623-0a6e1e09fcad/1694034340541-paigegreen_02.jpg",
      "schema:caption":"",
      "schema:creditText":"Paige Green Photography"
    },
    {
      "schema:url":"https://regen-registry.s3.amazonaws.com/projects/d1a8c4ec-4cf6-11ee-9623-0a6e1e09fcad/1694034384623-paigegreen_01.jpg",
      "schema:caption":"",
      "schema:creditText":"Paige Green Photography"
    }
  ]
}

As you can see, the anchored project metadata is overwritten with project page material. Additionally the (incorrect) metadata which was anchored includes things like regen:cfcCreditSerialNumbers and regen:additionalCertifications which are not applicable to this project metadata.

Expected behavior

The anchored metadata would be the JSON-LD the user inputs.


For Admin Use

  • Not duplicate issue
  • Appropriate labels and zenhub epics applied
  • Appropriate contributors tagged

The fields related to regen:cfcCreditSerialNumbers and others are only within the @context and don't actually affect the data itself. It's there to support all possible contexts (that we had so far).
But there's an issue indeed with https://schema.regen.network#galleryPhotos being added to the anchored metadata. I suspect this might be because we get this after fetching and compacting the metadata on the client side. This field should be compacted into regen:galleryPhotos and removed from the anchored metadata but somehow it appears as not compacted: https://schema.regen.network#galleryPhotos and doesn't get removed.

I've been trying to figure this out and I'm not having any real success.
One thing is that I'm having trouble reproducing the issue that Sam saw.
Another thing is that the code for the project form is quite complex to understand and I'm not super familiar.
I think for the sake of time, I'll put this back in the backlog and let someone else grab it (probably @blushi i guess).

While I couldn't repro the issue that Sam had, I can say that I saw some things that look to be caching problems.
For example, here's a set of instructions that I think reproduces an issue with the form and project page:

  1. create a project with all fields rendering successfully, i.e. you have gallery photos etc.
  2. then go to the edit project page screen for that project
  3. as soon as you arrive at the edit project page screen, change the project name and click save
  4. immediately go to project page, observe, no more gallery photos
  5. reload the page and then the gallery photos should reappear

Obviously this may be a separate issue, but it might also be related 🤷
I'm not 100% sure that this is a reproducer so please don't get too distracted by it