Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error rendering project page with custom metadata #2495

Open
paul121 opened this issue Oct 6, 2024 · 1 comment · May be fixed by #2496
Open

Error rendering project page with custom metadata #2495

paul121 opened this issue Oct 6, 2024 · 1 comment · May be fixed by #2496

Comments

@paul121
Copy link
Contributor

paul121 commented Oct 6, 2024

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:

export function getFieldLabel(fieldName: string) {
return fieldName.split(':')[1].replace(/([A-Z])/g, ' $1');
}


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
Copy link
Contributor Author

paul121 commented Oct 6, 2024

Maybe we need to add @graph to this?

function getUnknowFields(data: object, knownFields: string[]) {
return Object.entries(data).filter(
([key]) => !['@context', '@type', '@id', ...knownFields].includes(key),
);
}

@paul121 paul121 linked a pull request Oct 7, 2024 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant