regen-network / regen-web

:seedling: Website and marketplace application
https://app.regen.network
15 stars 9 forks source link

Error rendering project page with custom metadata #2495

Open paul121 opened 1 month ago

paul121 commented 1 month ago

I'm working on registering project/etc metadata with our own resolver. The webapp requests and receives this metadata but crashes the project page: https://dev.app.regen.network/project/MBS01-001

Screenshot from 2024-10-06 02-00-13

Clicking through the console error trace I found:

function W(r) {
    return r.split(":")[1].replace(/([A-Z])/g, " $1")
}

Searching codebase for /([A-Z])/g brings me to this:

https://github.com/regen-network/regen-web/blob/1f306059c5f5a0b3229ddf1f9464a0a938f19e53/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts#L94-L96


Below is the metadata I'm currently testing with (note the live version might change as I'm actively working on the resolver) - it seems like the regen webapp might not be compatible with all jsonld serializations? This metadata is a copy of the metadata C06-001 on mainnet with some text values changed: https://api.regen.network/data/v1/metadata-graph/regen:13toVhTxrr61w3iaLGGQL5AzmX9ss9DfQcuUATgT4L2dBb947DrAm2b.rdf

Notice that our data resolver returns a compacted serialization with a hard-coded context and includes @graph. It seems like regen web isn't compatible with this. At minimum I wouldn't expect this to crash the page.


{
    "@context": {
        "regen": "https://schema.regen.network#",
        "rfs": "http://framework.regen.network/schema/"
    },
    "@graph": [
        {
            "@id": "_:Nbba489fdb018474192c8238bc7faf60a",
            "@type": "regen:C06-Project",
            "http://schema.org/location": {
                "@id": "_:N6cd43617b43f43feb80a4a171a44f0de"
            },
            "http://schema.org/name": "Test project - mangrove",
            "regen:projectDeveloper": {
                "@id": "_:N8f39975300ba4760bb6b84dab000a2bc"
            },
            "regen:projectSize": {
                "@id": "_:N0e476aefd4654eb1a5cfa5ed3fd3ed1b"
            }
        },
        {
            "@id": "_:N0e476aefd4654eb1a5cfa5ed3fd3ed1b",
            "http://qudt.org/schema/qudt/numericValue": 267.0,
            "http://qudt.org/schema/qudt/unit": {
                "@type": "http://qudt.org/schema/qudt/Unit",
                "@value": "unit:HA"
            }
        },
        {
            "@id": "_:N8f39975300ba4760bb6b84dab000a2bc",
            "@type": "regen:Organization",
            "http://schema.org/description": "Doing test stuff",
            "http://schema.org/name": "Test"
        }
    ]
}
paul121 commented 1 month ago

Maybe we need to add @graph to this? https://github.com/regen-network/regen-web/blob/1f306059c5f5a0b3229ddf1f9464a0a938f19e53/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts#L9-L13