question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getResourceFromContext throws error on certain URLs

See original GitHub issue

I got the Failed to fetch resource: ... error on a url where I presume the error has to do with a urlencode issue. The url in my test was /library/Faculty&Staff. The getResourceFromContext function threw the error, with the jsonapi endpoint that it supposedly could not reach, which I was able to load manually in my browser. After removing the & from the url, so that it read /library/FacultyStaff the page loaded fine. Let me know if you need any more details.

Edit I just realized that this url was probably a custom override to the path alias pattern that was setup and sure enough it was. When I checked, generate automatically, it stripped out the &. My thought though is that why was translatePathFromContext able to return the jsonapi url in its response but getResourceFromContext could not load it? Seems like it still should work, or am I missing something?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
shadcncommented, Apr 22, 2022

Thanks.

We’re also running a few 1000+ pages sites with it. Ping here if you have any questions.

PS: Try the DrupalClient. This is where we’ll be focusing future work: https://next-drupal.org/docs/client

1reaction
shadcncommented, Apr 22, 2022

Yes. Agreed. It should still work. I just tested and confirmed this is a bug.

I’ll push a fix. A quick encodeURIComponent before assembling the route seems to fix it but I’d like to make sure it’s a proper fix.

slug = Array.isArray(slug)
      ? slug.map((s) => encodeURIComponent(s)).join("/")
      : slug

I’ll update here.

Thanks for reporting. Appreciate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "string" argument must be of type string or an instance of ...
I'm getting the same error in preview. My Drupal site base URL is http://localhost:8080/blog/drupal/web. EDIT: I've followed exactly the quick start ...
Read more >
How do I get Android string resources for flutter package?
I want to read the stings.xml file in another package. I'm creating a flutter package. What should I do? flutter example app string...
Read more >
Search API - Next.js for Drupal
Implement search using Drupal Search API.
Read more >
How to access Android resource strings from Flutter Plugin ...
private static String getResourceFromContext(@NonNull Context context, String resName) { final int ... getPackageName()); if (stringRes == 0) { throw new ...
Read more >
next-drupal - bytemeta
(experimental DrupalClient) "Error: Not Found" from drupal.translatePathFromContext() ... getResourceFromContext throws error on certain URLs. je34429.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found