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

Prevent errors when processing additional rdf metadata #2496

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

paul121
Copy link
Contributor

@paul121 paul121 commented Oct 7, 2024

Description

Testing to see if this fixes #2495


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • provided a link to the relevant issue or specification
  • provided instructions on how to test
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

How to test

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items
.

I have...

  • confirmed all author checklist items have been addressed
  • reviewed code correctness and readability
  • verified React components follow DRY principles
  • reviewed documentation is accurate
  • reviewed tests
  • manually tested (if applicable)

Copy link

netlify bot commented Oct 7, 2024

Deploy Preview for regen-website ready!

Name Link
🔨 Latest commit 3c45bc8
🔍 Latest deploy log https://app.netlify.com/sites/regen-website/deploys/6712ed98452f860008b18482
😎 Deploy Preview https://deploy-preview-2496--regen-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@paul121
Copy link
Contributor Author

paul121 commented Oct 7, 2024

This solves the issue of the page crashing. Compare these credit batch pages that have json-ld metadata with multiple @graph components (valid json-ld!) returned via our data resolver:

https://dev.app.regen.network/credit-batches/MBS01-001-20200101-20210101-001

to

https://deploy-preview-2496--regen-marketplace.netlify.app/credit-batches/MBS01-001-20200101-20210101-001

@blushi
Copy link
Member

blushi commented Oct 8, 2024

This solves the issue of the page crashing. Compare these credit batch pages that have json-ld metadata with multiple @graph components (valid json-ld!) returned via our data resolver:

https://dev.app.regen.network/credit-batches/MBS01-001-20200101-20210101-001

to

https://deploy-preview-2496--regen-marketplace.netlify.app/credit-batches/MBS01-001-20200101-20210101-001

This doesn't crash anymore, but the metadata is not displayed in "additional info" since it now excludes the whole graph, we would probably need to update our jsonLdCompact to work with @graphs

@paul121
Copy link
Contributor Author

paul121 commented Oct 9, 2024 via email

Copy link
Member

@blushi blushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but could we get this merged so the page stops crashing? It would still be useful to show these pages to clients while we are testing

Sure, pre-approving. Could you just put a comment in the code about that?

@paul121
Copy link
Contributor Author

paul121 commented Oct 9, 2024 via email

It's possible that the jsonld context fully defines a field label so that it doesn't contain a "regen:" prefix
Comment on lines +95 to +96
// Remove the field prefix and add space before capital letters.
return fieldName.replace(/[^:]*\:/, '').replace(/([A-Z])/g, ' $1');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes another bug we discovered where the page crashes if the field key doesn't have a colon prefix. This is a simple change to safely remove the first prefix: if one exists.

Compare: https://dev.app.regen.network/credit-batches/MBS01-001-20240601-20340531-002

And: https://deploy-preview-2496--regen-marketplace.netlify.app/credit-batches/MBS01-001-20240601-20340531-002

@paul121 paul121 changed the title Add @graph to unknown rdf fields Prevent errors when processing additional rdf metadata Oct 18, 2024
@paul121 paul121 requested a review from blushi October 18, 2024 23:27
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 this pull request may close these issues.

Error rendering project page with custom metadata
3 participants